首页 > 解决方案 > 弹出页面说我们已经发送了一封电子邮件,但没有任何内容发送到我的电子邮件重置电子邮件Django

问题描述

打扰了,这个问题困扰了我很久。即使有人有解释,我仍然无法理解。我可以用白话再解释一遍吗?谢谢你。

问题是弹出一个页面说已发送电子邮件,但我没有收到任何电子邮件!

password_reset/done/ 填写电子邮件地址并发送消息:我们已通过电子邮件向您发送设置密码的说明。如果几分钟后仍未收到,请检查您的垃圾邮件文件夹。

确实,终端中会出现一个链接页面,通知用户更改密码,如下:

     =?utf-8?b?ayBiZWxvdzpodHRwOi8vMTI3LjAuMC4xOjgwMDAvcmVzZXQvTWpVLzVwbS0zYmQ0?=
     =?utf-8?b?ZGZlNjUwODkzNmY3ZDBlNC8nJyc=?=
    From: webmaster@localhost
    To: aaaaaaa@hotmail.com
    Date: Mon, 12 Apr 2021 08:19:08 -0000
    Message-ID: <161821554833.3620.8514202595356349577@DESKTOP-EV07JLF>
    
    Someone asked for password reset for email aaaaaaa@hotmail.com. Follow the link below:
    http://127.0.0.1:8000/reset/MjY/5pq-538bd8f15e422996d747/

在留言区搜索给出的建议:

>1.For those of you facing the reset-email-sent-but-not-received issue. Make sure the email address, which you're entering into the reset field, actually belongs to a registered user. The clue is in the success message: "... if an account exists with the email you entered." So, if you're entering your own email address as a test, make sure you register a user with your email address.

>2.The email id, to which it needs to be emailed should be entered in users table. If the email id is in users table only then you will get the mail. Hope it helps 

>3.because you have to use the exact email which is used to create user account


My Django operation:

1. settings.py 

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
#Sender mail:
EMAIL_HOST_USER = 'ooxx@gmail.com'
EMAIL_HOST_PASSWORD = '........'

2. urls.py

from django.contrib.auth import views

path('password_change/', views.PasswordChangeView.as_view(), name='password_change'),

path('password_change/done/', views.PasswordChangeDoneView.as_view(), name='password_change_done'),

path('password_reset/', views.PasswordResetView.as_view(), name='password_reset'), 

path('password_reset/done/', views.PasswordResetDoneView.as_view(), name='password_reset_done'),

path('reset/<uidb64>/<token>/', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),

path('reset/done/', views.PasswordResetCompleteView.as_view(), name='password_reset_complete'),

标签: djangoemail

解决方案


推荐阅读