# The password reset email was not sent

**URL:** <https://forum.djangoproject.com/t/the-password-reset-email-was-not-sent/26274>\
**Category:** Getting Started\
**Created:** [December 19, 2023, 6:05am UTC](https://forum.djangoproject.com/t/the-password-reset-email-was-not-sent/26274 "2023-12-19T06:05:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HairlessVillager](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hairlessvillager/32/16144_2.png) [@HairlessVillager](https://forum.djangoproject.com/u/HairlessVillager)\
**Post date:** [December 19, 2023, 6:05am UTC](https://forum.djangoproject.com/t/the-password-reset-email-was-not-sent/26274/1 "2023-12-19T06:05:22Z")

</div>

Hello everyone! I’m learning the [Django authentication system](https://docs.djangoproject.com/en/5.0/topics/auth/default/). I was trying to build my own password reset page, but the backend not sent password reset emails. More details are as follows. (`<mosaic>` means sensitive information)

1. I can send email by `send_mail()`, which means the following code works:

```python
from django.core.mail import send_mail

send_mail(
    "Test",
    "Here is the message.",
    "hairlessvillager@<mosaic>.com",
    ["2542014055@<mosaic>.com"],
    fail_silently=False,
)

```

and the `settings.py` is as follows:

```python
# ...
DEFAULT_FROM_EMAIL = "hairlessvillager@<mosaic>.com"
EMAIL_HOST = "smtp.<mosaic>.com"
EMAIL_HOST_USER = "hairlessvillager@<mosaic>.com"
EMAIL_HOST_PASSWORD = "kxu<mosaic>iea"
EMAIL_USE_SSL = True
EMAIL_PORT = 465
# ...

```

1. The `urls.py` in app/ is as follows:

```python
# ...
urlpatterns = [
    path("", views.index, name="index"),
    path("accounts/", include("django.contrib.auth.urls")),
    path("accounts/profile/", views.profile, name="profile"),
    path("policy/", views.policy, name="policy"),
]

```

1. When there was no `passwird_reset_form.html` in `registration/`, url `/accounts/password_reset/` was the default Django administration password reset page, and **the email was sent successfully**. But when I wrote the `registration/passwird_reset_form.html` as follows:

```html
{% block content%}
    <p>Reset Password</p>
    <form method="get" action="{% url 'doctorhelper:password_reset_done' %}"> {# doctorhelper is the app_name#}
        {% csrf_token %}
        <table>
            <tr>
                <td>Email</td>
                <td>{{ form.email }}</td>
            </tr>
        </table>
        <input type="submit" value="Send Email!">
    </form>
{% endblock %}

```

the email was not sent, while the log was as follows:

```log
[19/Dec/2023 13:15:26] "GET / HTTP/1.1" 200 10805
[19/Dec/2023 13:15:27] "GET /accounts/login/ HTTP/1.1" 200 10672
[19/Dec/2023 13:15:28] "GET /accounts/password_reset/ HTTP/1.1" 200 575
[19/Dec/2023 13:15:33] "GET /accounts/password_reset/done/?csrfmiddlewaretoken=0VxPAdvCaEEbonSsc9fJacVhAy0JJKp0H3O3eVtQPpag8IqR3qLHnAIxxG7qiKX0&email=2542014055%40<mosaic>.com HTTP/1.1" 200 10070

```

I’d tried to set the form method to “post” but it was not allowed:

```log
Method Not Allowed (POST): /accounts/password_reset/done/
Method Not Allowed: /accounts/password_reset/done/
[19/Dec/2023 13:58:14] "POST /accounts/password_reset/done/ HTTP/1.1" 405 0

```

If any extra information is required, I’ll reply with it as soon as possible. Thanks for any help!

---

<div class="post-metadata">

**Author:** ![HairlessVillager](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/hairlessvillager/32/16144_2.png) [@HairlessVillager](https://forum.djangoproject.com/u/HairlessVillager)\
**Post date:** [December 19, 2023, 6:16am UTC](https://forum.djangoproject.com/t/the-password-reset-email-was-not-sent/26274/2 "2023-12-19T06:16:21Z")

</div>

Wait a minute! Maybe I’ve found the solution: just change the

```html
<form method="get" action="{% url 'doctorhelper:password_reset_done' %}"> {# doctorhelper is the app_name#}

```

to

```html
<form method="post">

```

and the email is sent.

It’s a little confused that the `<form>` has no attribute “action”.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 19, 2023, 6:18am UTC](https://forum.djangoproject.com/t/the-password-reset-email-was-not-sent/26274/3 "2023-12-19T06:18:34Z")

</div>

> [@HairlessVillager](#):
>
> It’s a little confused that the `<form>` has no attribute “action”.

No, that’s actually the typical / common / default process cycle for forms in Django.

The same view that generates the page containing the form is the view that will process the form submittal. Then, when _that_ processing is complete, the view redirects to the destination page.
