Django注册电子邮件未发送 [英] Django registration email not sending

查看:102
本文介绍了Django注册电子邮件未发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试获取django-registration-redux帐户激活电子邮件发送给新注册的用户。



我已经获得了所有与电子邮件无关的信息可以正常工作的部分,例如登录/注销和实际注册用户!当我注册时,它会自动以该用户身份登录。但是我从来没有收到激活邮件。



我尝试了各种不同的尝试来使其正常工作,我遵循了一些有关设置整个过程的教程,但是电子邮件仍然无法正常工作。

>

这里有一些代码设置,我使用的是我在线下载的注册模板。



settings.py

  INSTALLED_APPS =(
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'注册',
'synths',



#用户注册设置
REGISTRATION_OPEN =真实
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_AUTO_LOGIN =真

LOGIN_REDIRECT_URL ='/'
LOGIN_URL ='/ login /'

#我尝试包括此行,但仍然没有任何内容
#EMAIL_BACKEND ='django.core.mail.backends.console.EmailBackend'

#电子邮件
#首先,我尝试设置使用此CMD行调试服务器
#python -m smtpd -n -c DebuggingServer localhost:1025
#我不知道它是否有效!我没有错误,但是光标只是
#坐在在那里向我眨眼!我期望有一些输出告诉我
#服务器已启动
#这些是我用于该

EMAIL_HOST ='127.0.0.1'
EMAIL_PORT的设置= 1025
EMAIL_HOST_USER =''
EMAIL_HOST_PASSWORD =''

#然后我尝试使用自己的地址和smtp.live.com

EMAIL_HOST = 'smtp.live.com'
EMAIL_PORT = 25
EMAIL_HOST_USER ='myemailaddress@hotmail.com'
EMAIL_HOST_PASSWORD ='123123abcabc'

#仍然没有

我在这里缺少任何重要设置吗?



网址.py

 #包括在我的其他网址中
(r'^ accounts /',include('registration.backends .simple.urls')),

似乎都与教程和文档一致。就像我说的那样,注册可以完美地阻止电子邮件。



我注意到的一件事是,如果您希望用户激活他们的密码,则可能不应该使用自动登录= True帐户,但评论该行并没有改变任何东西,注册后我仍然自动登录。



我不知道,我迷失了它。我可能缺少某些设置,代码无法正常工作,python smtpd无法正常工作,或者我的smtp.live.com设置错误!



任何人都非常感谢!



编辑:尝试重置密码电子邮件功能时出现此错误

  / accounts / password / reset / 

服务器上不支持SMTP AUTH扩展的SMTPException。

请求方法:POST
请求URL:http:// localhost:8000 / accounts / password / reset /
Django版本:1.7.6
异常类型: SMTPException
异常值:服务器不支持SMTP AUTH扩展。

异常位置:C:\Python34\lib\smtplib.py,行613
Python可执行文件:C:\Python34\python.exe
Python版本:3.4.3

编辑2:使用这些设置,我得到密码/重置/完成页面,但没有收到实际的电子邮件

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

EMAIL_HOST ='127.0.0.1'
EMAIL_PORT = 1025


解决方案

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

仅在控制台上显示电子邮件。



相反,您应该使用

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

此外,使用现有的smtp服务器(例如gmail

)更方便,为此,您需要将它们添加到django设置文件中

  EMAI L_BACKEND ='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST ='smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER ='youruser@gmail.com'
EMAIL_HOST_PASSWORD ='gmail应用程序密码'#这不是您的gmail密码。
EMAIL_USE_TLS =真

有关密码的更多帮助,请参见此处


I've been trying to get the django-registration-redux account activation email to send to newly registered users.

I've gotten all non-email related parts to work, such as loggin in/out and actually registering the user! When i register, it automatically logs my in as that user. But i never get the activation email.

I've tried various different things to try get this to work, I've followed some tutorials on setting whole thing up but the emails still dont work.

heres some of the code setup, im using registration templates that i downloaded online.

settings.py

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'registration',
    'synths',
)


# user reg settings
REGISTRATION_OPEN = True
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_AUTO_LOGIN = True

LOGIN_REDIRECT_URL = '/'
LOGIN_URL = '/login/'

# i tried including this line but still nothing
# EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# email
# first i tried setting up the debbuging server with this CMD line
# python -m smtpd -n -c DebuggingServer localhost:1025
# i dont know if it worked!, i got no errors but the cursor just
# sat there blinking at me! i was expecting some output to tell me
# the server had started
# these were the settings i used for that

EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 1025
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''

# then i tried using my own address and smtp.live.com

EMAIL_HOST = 'smtp.live.com'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'myemailaddress@hotmail.com'
EMAIL_HOST_PASSWORD = '123123abcabc'

# still nothing

am i missing any important settings here?

urls.py

# included amongst my other urls
(r'^accounts/', include('registration.backends.simple.urls')),

seems all in order with the tutorials and documentation. like i said, registration works perfectly bar the emails.

one thing ive noticed is that you probably shouldn't have auto loggin = True if you want a user to activate their accounts, but commenting that line out didnt change anything, i still got logged in automatically after registering. Seems like a minor aside but maybe this has something to do with the emails not working?

i dunno, im lost with it. Either im missing some settings, the code doesnt work, python smtpd doesnt work, or my smtp.live.com settings are wrong!

any insigths greatly appreciated!

EDIT: when trying the 'reset password' email function i get this error

SMTPException at /accounts/password/reset/

SMTP AUTH extension not supported by server.

Request Method:     POST
Request URL:        http://localhost:8000/accounts/password/reset/
Django Version:     1.7.6
Exception Type:     SMTPException
Exception Value:    SMTP AUTH extension not supported by server.

Exception Location: C:\Python34\lib\smtplib.py in login, line 613
Python Executable:  C:\Python34\python.exe
Python Version:     3.4.3

EDIT 2: using these settings i get the the password/reset/done page but recieve no actual email

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

EMAIL_HOST = '127.0.0.1'
EMAIL_PORT = 1025

解决方案

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

will only display the email on the console.

Instead you should use

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

Moreover it is more convenient to use a existing smtp server like gmail

For that you need to add these to your django settings file

EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'                                                                             
EMAIL_HOST ='smtp.gmail.com'                                   
EMAIL_PORT = 587                                                             
EMAIL_HOST_USER = 'youruser@gmail.com'                              
EMAIL_HOST_PASSWORD = 'gmail app password' #This is not your gmail password.
EMAIL_USE_TLS = True

More help on the password can be found here

这篇关于Django注册电子邮件未发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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