python发送qq邮件

# coding:utf8

import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText


msg = MIMEMultipart()
msg['From'] = '123456@qq.com'
msg['To'] = '张三'
msg['Subject'] = '优美诗词库注册验证码'
message = '感谢您注册优美诗词库,点击下方链接完成注册!'
msg.attach(MIMEText(message))

mailserver = smtplib.SMTP('smtp.qq.com')

mailserver.ehlo()

mailserver.starttls()

mailserver.ehlo()
mailserver.login('123456@qq.com', '你的授权码')

mailserver.sendmail("123456@qq.com", "zhangsan@qq.com", msg.as_string())

mailserver.quit()
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页