Django password reset. Not sending mail

Darkade picture Darkade · Dec 22, 2011 · Viewed 10.6k times · Source

I'm trying to get the django password reset working but the reset email does not get sent.

I know my email is properly configured because the following works both in the shell and in one of my views (I'm using it to get support email to myself).

from django.core.mail import send_mail
send_mail('Subject here', 'Here is the message.',
          '[email protected]',['[email protected]'], fail_silently=False)

I can get to my reset password view (password/reset/) and after I give it my email it correctly redirects me to password/reset/done/ but it doesn't sends the email.

Here's my urls.py:

(r'^password/reset/$','django.contrib.auth.views.password_reset'),
(r'^password/reset/done/$','django.contrib.auth.views.password_reset_done'),
(r'^password/reset/confirm/$','django.contrib.auth.views.password_reset_confirm'),
(r'^password/reset/complete/$','django.contrib.auth.views.password_reset_confirm'),
(r'^password/change/$','django.contrib.auth.views.password_change'),
(r'^password/change/done/$','django.contrib.auth.views.password_change_done'),

Here's my password_reset_form.html:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="/media/css/style_login.css" />
    <title>Información de acceso requerida</title>
</head>
<body>
    <div id="wrapper">
        <h1>Recuperar password</h1>
        <p>Utilice este formulario cuando desee recuperar el password para su usuario.</p>
        {% if form.errors %}
        <p>No hay un usuario registrado con ese correo electronico.</p>
        {% endif %}
        <form method="post" action="{% url django.contrib.auth.views.password_reset_done %}">
            {% csrf_token %}
            {{ form }}
            <input class="login" type="submit" value="Recuperar" />
        </form>
    </div>
</body>

Any ideas? Thanks

Answer

Darkade picture Darkade · Jan 13, 2012

I should have mention I'm using hostgator as my provider. So this is my settings.py

EMAIL_HOST      = 'my-domain.com'
EMAIL_HOST_PASSWORD = 'my cpanel password'
EMAIL_HOST_USER = 'my cpanel user'
EMAIL_PORT      = 25
EMAIL_USE_TLS   = False
DEFAULT_FROM_EMAIL  = '[email protected]'
SERVER_EMAIL    = '[email protected]'

The above settings work!