python发送邮件
代码如下
import smtplib标签:python,server,发送,邮箱,message,email,邮件 From: https://www.cnblogs.com/yzjx1999/p/16892503.html
from email.mime.text import MIMEText
from email.header import Header
#引入email函数,smtp协议,需要在申请的邮箱打开SMTP协议,获取密码
auth_passports="密码原文"
server=smtplib.SMTP()
server.connect("邮箱申请的网站的名字")
server.login("发送邮箱",auth_passports)
sender="发送邮箱名"
receivers="接收者名字"
subject="python SMTP 邮件测试"
message=MIMEText("python mail test by YZJX1999","plain","utf-8")
message["subject"]=Header(subject,"utf-8")
server.sendmail(sender,receivers,message.as_string())
server.quit()