[Python] 纯文本查看 复制代码
import smtplib
from email.mime.text import MIMEText
from email.header import Header
# 配置邮箱服务器
smtpserver = "smtp.163.com"
# 用户/密码
user = "admin@163.com"
password = "123456"
# 发送者邮箱
sender = "admin@163.com"
# 接收者邮箱
receiver = "123456@163.com"
# 邮件主题
subject = "Python email test"
msg = MIMEText('<html><h1>你好!</h1></html>', "html", "utf-8")
msg["Subject"] = Header(subject, "utf-8")
if __name__ == '__main__':
smtp = smtplib.SMTP()
smtp.connect(smtpserver,25)
smtp.login(user,password)
smtp.sendmail(sender,receiver,msg.as_string())
smtp.quit()