Forums

getting error while resetting password with gmail in django

i'm getting error when i'm doing password reset with gmail in django. The error is-

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

my settings.py:

LOGIN_URL = 'login'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASS')

my urls.py:

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'),
]

i don't know to to set up google app paswword and all the stuff into my this environment.

Have a look at http://help.pythonanywhere.com/pages/SMTPForFreeUsers/. There's a link there to the Google documentation about how to set up app-specific passwords.

thak you

If you saved your email/password in environ variable for the first time. Please close your terminal and open it again, I hope this will solve your problem. I have run into the same problem and solved issues just like this.