Python模拟QQ发送邮件

#coding=utf-8

import smtplib
from email.mime.text import MIMEText
server = "smtp.qq.com"#协议

send_username = "1234567890@qq.com"#自己的账号
send_password = "ncadhqojjtxazejhd"#QQ邮箱授权码
send_title = "老师您好"#邮件标题
send_msg = "我是您的学生"#邮件内容
send_name = "哈哈哈哈哈哈"#发送者姓名
to_username = "459335930@qq.com"
msg = MIMEText(send_msg)
msg["subject"] = send_title
msg["From"] = send_name
#邮箱获取/登录/发送/退出
email = smtplib.SMTP(server,25)
email.login(send_username,send_password)
email.sendmail(send_username,to_username,msg.as_string())
email.quit()

 

posted @ 2023-02-11 22:17  Lauriee  阅读(10)  评论(0编辑  收藏  举报  来源