在测试发送邮件功能时出错
来源:3-17 邮件发送功能代码实现 mp4
慕移动0419469
2018-01-16
SMTPServerDisconnected Traceback (most recent call last)
<ipython-input-2-f35832660a49> in <module>()
----> 1 send_mail('Mydevops email','This is a test','sharkyun2017@gmail.com',['dockerhub@163.com'],fail_silently=False)
/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/__init__.pyc in send_mail(subject, message, from_email, recipient_list, fail_silently, auth_user, auth_password, connection, html_message)
60 mail.attach_alternative(html_message, 'text/html')
61
---> 62 return mail.send()
63
64
/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/message.pyc in send(self, fail_silently)
301 # send to.
302 return 0
--> 303 return self.get_connection(fail_silently).send_messages([self])
304
305 def attach(self, filename=None, content=None, mimetype=None):
/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.pyc in send_messages(self, email_messages)
98 return
99 with self._lock:
--> 100 new_conn_created = self.open()
101 if not self.connection:
102 # We failed silently on open().
/home/shark/virtualenv/imoocc_py2.7/lib/python2.7/site-packages/django/core/mail/backends/smtp.pyc in open(self)
56 })
57 try:
---> 58 self.connection = connection_class(self.host, self.port, **connection_params)
59
60 # TLS/SSL are mutually exclusive, so only attempt TLS over
/usr/lib64/python2.7/smtplib.pyc in __init__(self, host, port, local_hostname, timeout)
253 self.esmtp_features = {}
254 if host:
--> 255 (code, msg) = self.connect(host, port)
256 if code != 220:
257 raise SMTPConnectError(code, msg)
/usr/lib64/python2.7/smtplib.pyc in connect(self, host, port)
314 print>>stderr, 'connect:', (host, port)
315 self.sock = self._get_socket(host, port, self.timeout)
--> 316 (code, msg) = self.getreply()
317 if self.debuglevel > 0:
318 print>>stderr, "connect:", msg
/usr/lib64/python2.7/smtplib.pyc in getreply(self)
365 if line == '':
366 self.close()
--> 367 raise SMTPServerDisconnected("Connection unexpectedly closed")
368 if self.debuglevel > 0:
369 print>>stderr, 'reply:', repr(line)
SMTPServerDisconnected: Connection unexpectedly closed
1回答
-
Jeson
2018-01-16
用的gmail吗?在国内不太合适用,存在被墙的可能性,建议换个邮箱
00
相似问题