阿里云 邮件发送(Python)
Posted Bingo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了阿里云 邮件发送(Python)相关的知识,希望对你有一定的参考价值。
#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)的主要内容,如果未能解决你的问题,请参考以下文章
本地能正常发送邮件 阿里云服务器端发送邮件提示已经成功了 但是发送不过来 显示 Failure sending mail.