Gni*_*ohz 2 django login django-registration
我使用django-registration为我的项目管理用户注册,登录等.但是当我注册一个帐户时,我遇到了这个问题:
SMTPServerDisconnected
为了记录,我确实在settings.py中配置了与电子邮件相关的设置:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'myemail@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
Run Code Online (Sandbox Code Playgroud)
此外,我还拥有所需的所有模板.所以这个问题与此无关.
更多错误说明:
点击发送激活邮件后,它需要很长时间才能最终发出错误.
这是追溯(不完整):
SMTPServerDisconnected at /accounts/register/
Connection unexpectedly closed
last trace back:
/usr/lib/python2.7/smtplib.py in getreply
line = self.file.readline()
except socket.error as e:
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed: "
+ str(e))
if line == '':
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")
...
if self.debuglevel > 0:
print>>stderr, 'reply:', repr(line)
resp.append(line[4:].strip())
code = line[:3]
# Check that the error code is syntactically correct.
# Don't attempt to read a continuation line if it is broken.
Run Code Online (Sandbox Code Playgroud)
谢谢你的任何建议.
我认为至少有一个设置不正确.TLS需要端口587 [1]
EMAIL_PORT = 587
[1] http://support.google.com/mail/bin/answer.py?hl=zh-CN&answer=13287