标签:login sub 支持 encode 主机 quit header color server
# -*- coding: utf-8 -*- from email.header import Header from email.mime.text import MIMEText import smtplib def sendmail(subject, content): sender = ‘‘ # 发件人邮箱 password = ‘‘ # 发件人邮箱密码 recipients = ‘‘ # 收件人邮箱 host = ‘‘ # 发件人邮箱主机 msg = MIMEText(content, ‘plain‘, ‘utf-8‘) msg[‘From‘] = sender msg[‘To‘] = recipients msg[‘Subject‘] = Header(subject, ‘utf-8‘).encode() server = smtplib.SMTP(host, 25) server.login(sender, password) server.sendmail(sender, [recipients], msg.as_string()) server.quit()
标签:login sub 支持 encode 主机 quit header color server
原文地址:http://www.cnblogs.com/yestreenstars/p/6221723.html