【发布时间】:2015-05-17 11:52:33
【问题描述】:
我试图在我的 django 站点中执行忘记密码功能。 我的 settings.py 是:
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'email@gmail.com' #sample
EMAIL_HOST_PASSWORD = 'password'
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
我的 urls.py 是:
url(r'^user/password/reset/$',
'django.contrib.auth.views.password_reset',
{'post_reset_redirect' : '/user/password/reset/done/'},
name="password_reset"),
url(r'^user/password/reset/done/$',
'django.contrib.auth.views.password_reset_done'),
url(r'^user/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/user/password/done/'}),
url(r'^user/password/done/$',
'django.contrib.auth.views.password_reset_complete'),
我关注了this site,模板显示在那里。 当我输入电子邮件 ID 时,它显示它已邮寄。但我没有收到任何电子邮件。
我在控制台尝试过:
>>> from django.core.mail import EmailMessage
>>> email = EmailMessage('Subject', 'Message', to=['example@example.com'])
>>> email.send()
1
我收到了电子邮件.. 帮帮我..
【问题讨论】:
-
你能告诉你如何配置你的
EMAIL_BACKEND吗? -
我不知道。可能是默认的..
-
您是否向尝试恢复密码的用户提供了有效的电子邮件地址?
-
是的.. 我使用了一个有效的电子邮件地址
标签: python django forgot-password