我正在使用 Django 密码重置。
我的代码中有这个代码设置.py:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '[email protected] /cdn-cgi/l/email-protection'
EMAIL_HOST_PASSWORD = 'mypassword'
DEFAULT_FROM_EMAIL = '[email protected] /cdn-cgi/l/email-protection'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
SERVER_EMAIL = '[email protected] /cdn-cgi/l/email-protection'
它将我重定向到正确的页面,但不发送电子邮件。我已经检查了垃圾邮件文件夹等,但仍然没有:(
任何想法都非常感激!
Edit
我尝试使用控制台对其进行测试,但出现以下错误:
>>> email = EmailMessage('Mail test', 'this is a test', to=['[email protected] /cdn-cgi/l/email-protection'])
>>> 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.
Edit
我已经按照上面配置了settings.py。由于某种原因,它以前不起作用,但现在似乎可以了。当我跑步时
python manage.py shell
并使用 EmailMessage 和 send() 函数对其进行测试,我得到状态代码 1,并且收到电子邮件。但是,我仍然没有收到来自密码重置的电子邮件。有任何想法吗?谢谢各位的意见!