kaka
kaka

Reputation: 93

Django 3 - password reset - not generating email

I've followed multiple sources on how to set this up. Now everything seems working (no error) but I just don't see the email.

gmail - Allow less secure apps: ON

url.py

path('pw_reset/', auth_views.PasswordResetView.as_view(template_name="authacc/pw_reset.html"), name="reset_password"),
path('pw_done/', auth_views.PasswordResetDoneView.as_view(template_name="authacc/pw_done.html"), name="password_reset_done"),
path('pw_confirm/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name="authacc/pw_confirm.html"), name="password_reset_confirm"),
path('pw_complete/', auth_views.PasswordResetCompleteView.as_view(template_name="authacc/pw_complete.html"), name="password_reset_complete"),

settings.py

#SMTP Configuration
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')

What I've tried... use debuggingserver to check the email locally.

settings.py

EMAIL_HOST = 'localhost' EMAIL_PORT = 1025

cmd

python -m smtpd -n -c DebuggingServer localhost:1025

I can see the "Password reset sent" page, but no email is generated. So I suspect there's something wrong with the default PasswordResetView?

Probably similar problem, but unresolved: Reset password emails in Django

Upvotes: 0

Views: 397

Answers (1)

kaka
kaka

Reputation: 93

The code was fine. Something was off with the email formatting. I didn't experiment enough, but ".com" ending seems fine, ".me" isn't.

Upvotes: 0

Related Questions