码迷,mamicode.com
首页 > 编程语言 > 详细

阿里云 邮件发送(Python)

时间:2019-04-08 13:58:11      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:smt   sub   send   debug   enc   mail   阿里   python   evel   

#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()

阿里云 邮件发送(Python)

标签:smt   sub   send   debug   enc   mail   阿里   python   evel   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!