Django 密码重置电子邮件从不发送
Django Password reset email never sends
我正在使用内置的 Django 密码重置功能,出现 'password reset sent' 页面,但电子邮件从未发送。我的电子邮件设置如下:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'my_email'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = 'my_password'
我在开发过程中加入了以下内容,但不确定是否有必要:
ALLOWED_HOSTS = ['localhost']
控制台显示:
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on localhost:8000
From: myemail@gmail.com
To: anotheremail@hotmail.com
Date: Wed, 17 Feb 2016 04:53:17 -0000
Message-ID: <some_id@toms-macbook-air.local>
看起来一切都在发生,但电子邮件从未发送。我是不是做错了什么?
您正在使用仅用于测试的虚拟电子邮件后端。换行
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
到
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
来自docs:
Console backend
Instead of sending out real emails the console backend just writes the
emails that would be sent to the standard output. By default, the
console backend writes to stdout. You can use a different stream-like
object by providing the stream keyword argument when constructing the
connection.
我正在使用内置的 Django 密码重置功能,出现 'password reset sent' 页面,但电子邮件从未发送。我的电子邮件设置如下:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'my_email'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_HOST_PASSWORD = 'my_password'
我在开发过程中加入了以下内容,但不确定是否有必要:
ALLOWED_HOSTS = ['localhost']
控制台显示:
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Subject: Password reset on localhost:8000
From: myemail@gmail.com
To: anotheremail@hotmail.com
Date: Wed, 17 Feb 2016 04:53:17 -0000
Message-ID: <some_id@toms-macbook-air.local>
看起来一切都在发生,但电子邮件从未发送。我是不是做错了什么?
您正在使用仅用于测试的虚拟电子邮件后端。换行
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
到
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
来自docs:
Console backend
Instead of sending out real emails the console backend just writes the emails that would be sent to the standard output. By default, the console backend writes to stdout. You can use a different stream-like object by providing the stream keyword argument when constructing the connection.