import smtplib
from email.mime.text import MIMEText
from email.utils import formataddr
# 写邮件的内容
msg = MIMEText('城啊', 'plain', 'utf-8')
msg['From'] = formataddr(["老板", '自己邮箱@qq.com'])
msg['To'] = formataddr(["诚哥", '对方@qq.com'])
msg['Subject'] = "约吗"
server = smtplib.SMTP_SSL("smtp.qq.com", 465)
server.login("自己QQ号", "授权码") # 授权码
server.sendmail('自己邮箱@qq.com', ['对方@qq.com', ], msg.as_string())
server.quit()
转载于:https://www.cnblogs.com/shuiguoyuan/p/11551421.html