我正在使用 Django 密码重置。
我的settings.py中有这段代码:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'myusername@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
DEFAULT_FROM_EMAIL = 'myusername@gmail.com'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
SERVER_EMAIL = 'myusername@gmail.com'
它将我重定向到正确的页面,但它不发送电子邮件。我检查了垃圾邮件文件夹等,但仍然没有:(
任何想法都非常感谢!
编辑
我尝试使用控制台对其进行测试,但出现以下错误:
>>> email = EmailMessage('Mail test', 'this is a test', to=['myusername@gmail.com'])
>>> email.send()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/message.py", line 255, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 88, in send_messages
new_conn_created = self.open()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 55, in open
self.connection.login(self.username, self.password)
File "/usr/lib/python2.7/smtplib.py", line 576, in login
raise SMTPException("SMTP AUTH extension not supported by server.")
SMTPException: SMTP AUTH extension not supported by server.
编辑
我的 settings.py 配置如上。由于某种原因,它以前不起作用,但现在似乎是。当我跑
python manage.py shell
并使用 EmailMessage 和 send() 函数对其进行测试,我得到状态码 1,我收到了电子邮件。但是,我仍然没有收到来自 password_reset 的电子邮件。有任何想法吗?谢谢各位的意见!