带有 Django 的 Amazon SES SMTP [英] Amazon SES SMTP with Django

查看:86
本文介绍了带有 Django 的 Amazon SES SMTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Amazon 新的 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

推荐答案

我找到了一个更简单的解决方案,它允许我使用 Django 的内置邮件类,这样我仍然可以获得我的管理员错误电子邮件报告等.

I 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 install)

Download and install (python setup.py install)

然后只需更改您的设置即可使用这个新的电子邮件后端:

Then just change your settings to use this new email backend:

EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'

其余设置正常:

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

这篇关于带有 Django 的 Amazon SES SMTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆