1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Python 网易邮箱简单发送邮件

Python 网易邮箱简单发送邮件

时间:2022-03-26 11:59:18

相关推荐

Python 网易邮箱简单发送邮件

import smtplib #导入PyEmailfrom email.mime.text import MIMETextmsg_from="130xxxxx490@" #发件人邮箱passwd="xyy0820" #客户端授权密码,不是邮箱登陆密码msg_to="19xxxxxx59@" #接收人邮箱subject="邮件主题"content="邮件内容"msg=MIMEText(content)msg["Subject"]=subjectmsg["From"]=msg_frommsg["To"]=msg_totry:#s = smtplib.SMTP_SSL("",465)s = smtplib.SMTP("",25)s.login(msg_from, passwd)s.sendmail(msg_from, msg_to, msg.as_string())print ("发送成功")except smtplib.SMTPException as e:print ("发送失败")finally:s.quit()

代码如上,在运行过程中我们可能会遇到各种问题。

问题一、提示import smtplib 报错 ,并且有Could not find a version that satisfies the requirement smtplib (from versions: )

No matching distribution found for smtplib错误信息,是因为没有导入PyEamil第三方包。

问题二、提示ss.login(msg_from,passwd) 报错,并且有smtplib.SMTPAuthenticationError: (535, b'Error: authentication failed' 错误信息,是因为passwd是客户端授权密码,不是邮箱登陆密码。

问题三、邮件的成功的发送需要开启邮件设置

其他链接帮助:/secondtonone1/p/8213749.html 网易邮箱发送邮件升级代码

/dearmorning/article/details/81069075 网易邮箱发送邮件问题帮助

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。