Defaut password reset form error: with Django and gmail

Defaut password reset form error: with Django and gmail

我目前正在尝试为我的 site.I 创建一个密码重置表单,我已经查看了几个与此类似的问题,但 none 为我提供了答案。我还在 gmail 网站上创建了一个应用程序密码,我正在使用它,因为我有 2FA。我收到错误:

SMTPSenderRefused at /password-reset/
(530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError n8sm12016723wrm.46 - gsmtp', 'webmaster@localhost')

我的settings.py代码:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAL_HOST_USER = '***********'
EMAIL_HOST_PASSWORD = '*********'

urls.py 文件,其中视图已被实例化:


from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth import views as auth_views
from django.urls import path, include 
from users import views as user_views

urlpatterns = [
    path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password_reset'),
    path('password-reset/done', auth_views.PasswordResetDoneView.as_view(template_name='users/password_reset_done.html'), name='password_reset_done'),
    path('password-reset-confirm/<uidb64>/<token>', auth_views.PasswordResetConfirmView.as_view(template_name='users/password_reset_confirm.html'), name='password_reset_confirm'),  
]

为此,您必须在您的邮件帐户中允许第三方访问

Using the gmail app password through you can send the email not provide the actual password and no one can login in your account. Without enable less secure apps setting here is give the link try and it's work let me know if it right google or gmail app password

中将实际密码更改为您的应用程序密码后

setting.py 文件 EMAIL_HOST_PASSWORD = 'your app password' 由 google 提供 其他常数不变

if you do not use 2 step email verification you need to use third party service here i give the link you see sendgrid

关注我给link Password reset django 如果答案正确,请告诉我正确与否

重新启动系统应该可以。