python - Django send_mail 在 1.7 中失败说没有 django_smtp_ssl

标签 python django

我正在将一些 Django 1.5 移植到 1.7,但 send_mail() 调用对我来说失败了。我检查了the docs他们似乎表明我的语法仍然没问题。

我尝试在 Django shell 模式下获取跟踪信息以在此处共享,但仍然以同样的方式失败。我只是简单地调用 send_mail() :

from django.core.mail import send_mail
send_mail('Test mail', 'This is a test', '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee8f8a8a9cae9d879a8bc08d8f" rel="noreferrer noopener nofollow">[email protected]</a>' ['<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="10717474622250637964753e7371" rel="noreferrer noopener nofollow">[email protected]</a>'], fail_silently=False)

我得到了一个回溯

ImportError: No module named django_smtp_ssl

现在,smtp_ssl 看起来就像来自 smtplib。我尝试将 smtplib 与 send_mail 一起导入,但这也没有帮助。

在我的 settings.py 中,我有常用的端口和主机详细信息,并且

EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'

有什么建议吗?

-谢谢,罗斯。

最佳答案

没有什么比整理一个问题来帮助自己找到答案更好的了。

看起来 EMAIL_BACKEND 位置在此版本的 Django 中已更改。所以答案(对于像我一样用谷歌搜索但没有找到解决方案的人来说)就是在你的settings.py 文件中更新后端指针。

现在是:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

干杯, 罗斯。

关于python - Django send_mail 在 1.7 中失败说没有 django_smtp_ssl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28075061/

相关文章:

Python,在内存中写入zip到文件

python - 使用列表元素进行正则表达式搜索以在大型文档中查找匹配项

Python 3 假设模块命名空间

javascript - 需要 VueJS Getter 仅以数组形式返回最后一个 JSON 属性的所有值

python - 使用字符串替换的 Django 批量更新

html - 在 Django 中检索多个选择选项时出错

python - Django il8n - 在 Windows 上翻译外部应用程序

python - WebDriverException : Message: Service chromedriver unexpectedly exited. 状态代码为:127

javascript - 具有某些功能的发送按钮

python - 如何从 Python 字典中的键中删除尾随空格?