阿里云 邮件发送(Python)

时间:2019-04-08 12:27:25   收藏:0   阅读:190
#coding:utf8
from smtplib import SMTP_SSL
from email.header import Header
from email.mime.text import MIMEText

mail_info = {
    "from": "",
    "to": "",
    "host": "smtp.qq.com",
    "username": "",
    "password": "",
    "subject": "test",
    "text": "email test",
    "encoding": "utf-8"
}
smtp = SMTP_SSL(mail_info["host"])
smtp.set_debuglevel(1)
smtp.ehlo(mail_info["host"])
smtp.login(mail_info["username"], mail_info["password"])
msg = MIMEText(mail_info["text"], "plain", mail_info["encoding"])
msg["Subject"] = Header(mail_info["subject"], mail_info["encoding"])
msg["from"] = mail_info["from"]
msg["to"] = mail_info["to"]
smtp.sendmail(mail_info["from"], mail_info["to"], msg.as_string())
smtp.quit()

原文:https://www.cnblogs.com/tongchengbin/p/10669619.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!