import smtplib
import time
from email.mime.text import MIMEText
import requests
from docopt import docopt
def sendMail(subject, body):
try:
"""发送邮件"""
msg = MIMEText(body)
msg["Subject"] = subject
msg["From"] = "的qq邮箱" # from
msg["To"] = "的qq邮箱" # to
s = smtplib.SMTP_SSL("smtp.qq.com", 465)
s.login("xxxx@qq.com", "你的qq邮箱授权码") # 这里的第二个参数为qq邮箱授权码,不要填你的密码
s.sendmail("xxxx@qq.com", ["xxxx@qq.com", ], msg.as_string()) # from,to,msg
s.quit()
print("邮件发送成功!")
except Exception as e:
print("邮件发送失败~~" + e.message)
Python3之QQ发送邮件代码实现
最新推荐文章于 2020-11-28 16:46:46 发布