我花了很多时间开发表单并将所有部分连接在一起,现在我无法通过django设置连接到我的smtp服务器。这是我的设置......
DEFAULT_FROM_EMAIL = 'auto@domain.com'
EMAIL_HOST = 'smtp.mailhost.com'
EMAIL_HOST_USER = 'auto@domain.com'
EMAIL_HOST_PASSWORD = 'password'
EMAIL_USE_TLS = True
EMAIL_PORT = 465
我试图通过我的表单发送它并且它不起作用所以我试图通过shell发送一个..
from django.core.mail import send_mail
send_mail('subject','message','auto@domain.com', ['me@domain.com'], fail_silently=False)
我得到了这个追溯......
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/__init__.py", line 62, in send_mail
return mail.send()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/message.py", line 286, in send
return self.get_connection(fail_silently).send_messages([self])
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 92, in send_messages
new_conn_created = self.open()
File "/usr/local/lib/python2.7/dist-packages/django/core/mail/backends/smtp.py", line 50, in open
self.connection = connection_class(self.host, self.port, **connection_params)
File "/usr/lib/python2.7/smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "/usr/lib/python2.7/smtplib.py", line 312, in connect
(code, msg) = self.getreply()
File "/usr/lib/python2.7/smtplib.py", line 363, in getreply
raise SMTPServerDisconnected("Connection unexpectedly
关闭“) SMTPServerDisconnected:连接意外关闭
答案 0 :(得分:1)
您应该重新检查您使用的数据:登录,密码等
如果没有帮助,请尝试使用端口587 。
SMTP使用此版本。我希望它会有所帮助。
495现已弃用。