Django密码重置.不发送邮件 [英] Django password reset. Not sending mail

查看:43
本文介绍了Django密码重置.不发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重置django密码,但重置电子邮件未发送.

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.',
          'admin@mydomain.com',['me@gmail.com'], fail_silently=False)

我可以进入我的重置密码视图( password/reset/),并在给我电子邮件后将其正确重定向到 password/reset/done/,但是它不会发送电子邮件.

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.

这是我的 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'),

这是我的 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>

有什么想法吗?谢谢

推荐答案

我应该提到我正在使用hostgator作为提供程序.这就是我的settings.py

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  = 'webmaster@my-host.com'
SERVER_EMAIL    = 'root@my-domain.com'

以上设置有效!

这篇关于Django密码重置.不发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆