0

I setup a PasswordResetView with a template that has a submit button, I also setup the necessary configuration for sending using a Gmail account but then when I try to send a password reset to an email, the console returns a 302 response and no email is received. I already allowed less secure apps in my gmail account, but it still doesn't send any email. Below are the details of my setup.

URL:

path('password-reset/', auth_views.PasswordResetView.as_view(template_name='users/password_reset.html'), name='password_reset'),

settings.py:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'my@gmail.com'
EMAIL_HOST_PASSWORD = 'mypass'

Reset Password Template:

{% extends "blog/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
    <div class="content-section">
        <form method="POST">
            {% csrf_token %}
            <fieldset class="form-group">
                <legend class="border-bottom mb-4 pb-2">Reset Password</legend>
                {{ form|crispy }}
            </fieldset>
            <div class="form-group">
                <button class="btn btn-outline-info" type="submit">Request Password Reset</button>
            </div>
        </form>
    </div>
{% endblock content %}

Server Response:

enter image description here

Vince Gonzales
  • 855
  • 3
  • 20
  • 39

1 Answers1

0

Seems Django works well on web pages , it could be some errors during sending.

I think it might be your Email settings , try setting

SERVER_EMAIL='my@gmail.com'

django would send email from localhost by default, which is not accepted by Gmail

possible duplicated: Django send_mail not working

Leo Que
  • 55
  • 1
  • 10