我尝试在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发布于 2019-05-16 16:53:47
您正在编辑Django默认设置,这是一种奇怪的更改配置的方式,但Bitnami似乎推荐这种方法。该设置似乎未正确应用,因为test命令仍使用默认SMTP后端。
要检查的事项:
是否已实际应用./manage.py shell -c 'from django.conf import settings; print(settings.EMAIL_BACKEND)'
django-ses安装到系统中?最好以根sudo pip install django-seshttps://stackoverflow.com/questions/56110362
复制相似问题