我试图在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
答案 0 :(得分:0)
您正在编辑Django默认设置,这是更改配置的怪异方法,但是看来Bitnami建议使用此方法。似乎该设置未正确应用,因为测试命令仍使用默认的SMTP后端。
要检查的事情:
./manage.py shell -c 'from django.conf import settings; print(settings.EMAIL_BACKEND)'
django-ses
是否已安装到系统中?最好以root sudo pip install django-ses