#发送邮件
msg = MIMEText('邮件内容', 'plain', 'utf-8')
msg['From'] = formataddr(["测试", '287013373@qq.com'])
msg['To'] = formataddr(["测试", '287013373@qq.com'])
msg['Subject'] = "主题"
server = smtplib.SMTP("smtp.qq.com", 25)
value= server.login("287013373@qq.com","123456")
server.sendmail('287013373@qq.com', ['287013373@qq.com', ], msg.as_string())
server.quit()
value= server.login("287013373@qq.com","123456")这段代码执行失败
Connected to pydev debugger (build 162.1967.10)
Traceback (most recent call last):
File "F:JetBrainsPyCharm 2016.2.3helperspydevpydevd.py", line 1580, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "F:JetBrainsPyCharm 2016.2.3helperspydevpydevd.py", line 964, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "F:JetBrainsPyCharm 2016.2.3helperspydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Tang/Desktop/Workspaces/Meth/Preactices.py", line 77, in <module>
value= server.login("287013373@qq.com","123456")
File "C:Python35libsmtplib.py", line 720, in login
initial_response_ok=initial_response_ok)
File "C:Python35libsmtplib.py", line 630, in auth
(code, resp) = self.docmd("AUTH", mechanism + " " + response)
File "C:Python35libsmtplib.py", line 420, in docmd
return self.getreply()
File "C:Python35libsmtplib.py", line 393, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
大家可以帮我看一下吗