密码重置 - 发送邮件不起作用

时间:2013-10-07 07:08:58

标签: python django email django-mailer

Setting.py-

EMAIL_BACKEND = "mailer.backend.DbBackend"
EMAIL_SUBJECT_PREFIX = "[.....]"

EMAIL_HOST          = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'tester@@abcd'
EMAIL_HOST_USER     = 'tester.abcd@gmail.com'
EMAIL_PORT          = 587
EMAIL_USE_TLS       = True

DEFAULT_FROM_EMAIL  = 'tester.abcd@gmail.com'
DEFAULT_ADMIN_EMAIL  = 'tester.abcd@gmail.com'
TEMPORARY_CC_EMAIL = 'tester.abcd@gmail.com'
CONTACTUS_EMAIL = 'tester.abcd@gmail.com'
JOBAPPLY_EMAIL = 'tester.abcd@gmail.com'

urls.py:

urlpatterns = patterns('django.contrib.auth.views',
 url(r'^password-reset/$', 'password_reset', {
      'template_name': 'profiles/password_reset_form.html',
    'password_reset_form': PassResetForm
  }, name='password-reset'),
 url(r'^password-reset-process/$', 'password_reset_done', {
    'template_name': 'profiles/password_reset_done.html',
  }, name='password-reset-done'),
 url(r'^password-reset-confirm/(?P<uidb36>[0-9a-zA-Z]{1,13})-(?P<token>.+)/$',
    'password_reset_confirm',
    {'template_name': 'profiles/password_reset_confirm.html',},
    name='password-reset-confirm'),
 url(r'^password-reset-complete', 'password_reset_complete', {
    'template_name': 'profiles/password_reset_complete.html',
  }, name='password-reset-complete'),

这是我的代码,当我输入我的邮件并点击正确提交它重定向到下一页但邮件没有发送,是否有任何pblm与此代码

1 个答案:

答案 0 :(得分:0)

您应首先测试问题是来自您的代码还是电子邮件后端。

以下是设置Django控制台电子邮件后端的方法:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

当您在本地开发计算机python manage.py runserver上运行服务器时,这应该在控制台中输出电子邮件。

如果电子邮件正确打印到控制台中,那么您的配置可能出现问题:

EMAIL_HOST          = 'smtp.gmail.com'
EMAIL_HOST_PASSWORD = 'tester@@abcd'
EMAIL_HOST_USER     = 'tester.abcd@gmail.com'
EMAIL_PORT          = 587
EMAIL_USE_TLS       = True

或在这里:

EMAIL_BACKEND = "mailer.backend.DbBackend"