带有Django的Amazon SES SMTP [英] Amazon SES SMTP with Django
问题描述
我正在尝试将Django的新SMTP服务用于Django 1.3.1的SES,但运气不佳.
I'm trying to use Amazon's new SMTP service for SES with Django 1.3.1 but I'm not having much luck.
我已经创建了我的SES SMTP凭据,并在我的设置中添加了它:
I've created my SES SMTP credentials and have this in my settings:
EMAIL_USE_TLS = True
EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
EMAIL_HOST_USER = 'my-smtp-user'
EMAIL_HOST_PASSWORD = 'my-smtp-password'
EMAIL_PORT = 465
然后,我尝试发送测试电子邮件(从和发送到已验证的电子邮件地址):
Then I try sending a test email (from and to verified email addresses):
from django.core.mail import send_mail
send_mail('Test subject', 'This is the body', 'info@abc.com',['hello@abc.com'], fail_silently=False)
但是出现以下错误:
SMTPServerDisconnected: Connection unexpectedly closed
我可以远程登录到服务器:
I can telnet to the server:
telnet email-smtp.us-east-1.amazonaws.com 465
有什么想法吗?
谢谢, G
推荐答案
感谢大家的建议,但我终于找到了一个更简单的解决方案,该解决方案使我可以使用Django的内置邮件类,因此仍然可以得到管理员错误电子邮件报告等.
Thanks everyone for the recommendations but I finally found a much simpler solution that would allow me to use Django's built-in mail classes so I can still get my admin error email reports etc.
多亏了这个小小的美丽,我才能够使用SES SMTP而没有任何问题:
Thanks to this little beauty I was able to use SES SMTP without any problems:
https://github.com/bancek/django-smtp-ssl
下载并安装(python setup.py安装)
Download and install (python setup.py install)
然后只需更改设置即可使用此新电子邮件后端:
Then just change your settings to use this new email backend:
EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
其余设置与正常情况相同:
The rest of the settings are as per normal:
EMAIL_HOST = 'email-smtp.us-east-1.amazonaws.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = 'my_smtp_username'
EMAIL_HOST_PASSWORD = 'my_smtp_password'
EMAIL_USE_TLS = True
很好.
G
这篇关于带有Django的Amazon SES SMTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!