email.py 邮件发送

 1 import smtplib
 2 from email.mime.text import MIMEText 
 3 msg = MIMEText('发送内容,自行编辑','plain','utf-8')
 4 from_addr = '[email protected]'
 5 #授权码
 6 from_pwd ="ozgdpapqwyoxghfi"
 7 to_addr= '[email protected]'
 8 
 9 smtp_srv = "smtp.qq.com"
10 
11 try:
12 srv = smtplib.SMTP_SSL(smtp_srv.encode(),465)
13 srv.login(from_addr,from_pwd)
14 srv.sendmail(from_addr,[to_addr],msg.as_string())
15 srv.quit()
16 except Exception as e:
17 print(e)

这段代码 能简单实现邮件发送 ,只是qq邮箱的发送

猜你喜欢

转载自www.cnblogs.com/LingnM-Insane/p/9661501.html
今日推荐