import smtplibfrom email.mime.text import MIMEText # 服务器SMPTserver = "smtp.163.com"# 发送邮件的地址(自己的邮箱地址)sender = "[email protected]"# 授权密码(不等同于登录密码)password = "xxxxxxxxxxx"# 发送的文本内容message = "zhf is a good man"# 转为邮件文本msg = MIMEText(message)msg["Subject"] = "zhf"msg["From"] = sender# 连接smtp服务器mailServer = smtplib.SMTP(SMPTserver, 25)# 登录mailServer.login(sender, password)# 发送邮件mailServer.sendmail(sender, ["[email protected]"], msg.as_string())mailServer.quit()
原文地址:https://www.cnblogs.com/zhf123/p/11525005.html
时间: 2024-11-15 06:19:11