【发布时间】:2019-09-30 07:07:34
【问题描述】:
我尝试在 AWS 上设置一个 Weblate 实例来发送密码重置电子邮件。我按照以下步骤操作:
pip install boto
pip install django-ses
sudo vim /opt/bitnami/apps/django/lib/python3.7/site-packages/Django-2.1.4-py3.7.egg/django/conf/global_settings.py
EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_ACCESS_KEY_ID = 'xxxx'
AWS_SECRET_ACCESS_KEY = 'xxx'
但是它仍然无法正常工作,而且我没有收到任何错误。我的 AWS 密钥拥有 SES 的完全权限。
更新:
如果我从./manage.py shell 运行 send_mail,我会得到以下输出:
>>> send_mail('Subject here', 'Here is the message.', 'xx@gmail.com',['xx@gmail.com'], fail_silently=False)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/bitnami/apps/weblate/venv/lib/python3.7/site-packages/django/core/mail/__init__.py", line 60, in send_mail
return mail.send()
File "/opt/bitnami/apps/weblate/venv/lib/python3.7/site-packages/django/core/mail/message.py", line 291, in send
return self.get_connection(fail_silently).send_messages([self])
File "/opt/bitnami/apps/weblate/venv/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 103, in send_messages
new_conn_created = self.open()
File "/opt/bitnami/apps/weblate/venv/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 63, in open
self.connection = self.connection_class(self.host, self.port, **connection_params)
File "/opt/bitnami/python/lib/python3.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/opt/bitnami/python/lib/python3.7/smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "/opt/bitnami/python/lib/python3.7/smtplib.py", line 307, in _get_socket
self.source_address)
File "/opt/bitnami/python/lib/python3.7/socket.py", line 727, in create_connection
raise err
File "/opt/bitnami/python/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
【问题讨论】:
-
如果没有任何类型的日志,很难说出问题所在。
-
尝试至少运行
./manage.py check,它会显示任何连接问题(这些问题也应该在管理界面中可见)。如果这可行,那么实际发送电子邮件存在问题(不确定 ses 后端的行为以及何时验证凭据),这些应该在 celery 日志中可见。 -
sudo ./manage.py check System check identified no issues (0 silenced). -
对不起,我应该提到
./manage.py check --deploy,但你还是收到了电子邮件错误。
标签: django amazon-ses weblate