Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django password reset. Not sending mail

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

like image 452
Darkade Avatar asked Dec 22 '11 21:12

Darkade


People also ask

How can I get Django password reset token?

Registration and forgot password routes We're going to create four URL endpoints: /register that includes the registration form and sends the activation token email . /activate that validates the activation token from the email. /password reset that includes the forgot password form and sends the reset token email .


1 Answers

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!

like image 74
Darkade Avatar answered Oct 17 '22 09:10

Darkade