email.py 邮件发送
程序员文章站
2022-06-22 11:14:17
这段代码 能简单实现邮件发送 ,只是qq邮箱的发送 ......
1 import smtplib 2 from email.mime.text import mimetext 3 msg = mimetext('发送内容,自行编辑','plain','utf-8') 4 from_addr = '1160780114@qq.com' 5 #授权码 6 from_pwd ="ozgdpapqwyoxghfi" 7 to_addr= '1160780114@qq.com' 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邮箱的发送