Python发送邮件(支持中文)

# -*- 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()
上一篇:C#中无边框窗体拖动


下一篇:Effective Java 创建和销毁对象