import smtplib from email.mime.text import MIMEText #邮件正文 from email.header import Header #邮件头 #登录邮件服务器 smtp_obj = smtplib.SMTP_SSL("smtp.email.qq.com",465) #发件人邮箱中的SMTP服务器,端口是25 smtp_obj.login("[email protected]","xxxx-sd#gj") #括号中对应的是发件人邮箱账号、邮箱密码 smtp_obj.set_debuglevel(1) #显示调试信息 #设置邮件头信息 msg = MIMEText("Hello,小哥哥!","plain","utf-8") msg["From"] = Header("来自娜美的问候","utf-8") msg["To"] = Header("牛牛","utf-8") msg["Subject"] = Header("娜美的信","utf-8") #主题 #发送 smtp_obj.sendmail("[email protected]",["[email protected]","[email protected]"], msg.as_string())
标签:发邮件,utf,python,smtp,Header,msg,obj,com From: https://www.cnblogs.com/mastershun/p/17220691.html