使用python3发送qq邮件

import smtplib
from email.mime.text import MIMEText

def send_qq_email(subject, body, sender, auth, recipient):
# 连接到 QQ 邮箱的 SMTP 服务器
   #auth为在qq客户端生成的“生成授权码
    server = smtplib.SMTP_SSL("smtp.qq.com", 465)
# 登录邮箱
server.login(sender, password)
# 创建邮件正文
msg = MIMEText(body, "plain", "utf-8")
# 设置邮件主题
msg["Subject"] = subject
# 发送邮件
server.sendmail(sender, recipient, msg.as_string())
# 断开连接
server.quit()

if __name__ == '__main__':
send_qq_email("Hello", "Hello, world!", "839276@qq.com", auth=auth,
recipient= "jin@126.com")
posted @   yiwei1989100  阅读(58)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
点击右上角即可分享
微信分享提示