Python发邮件-QQ邮箱

1、在QQ邮箱修改配置——开启pop3

 

 开启后是这个样子的,授权过程中,会有一个授权码,要记住,授权码我们代码中会用到

 

 发送邮件代码

import yamail

username = "发件人QQ账号@qq.com"
password = "授权码"
host = "smtp.qq.com" #smtp.163.com
port = 465

mail = yamail.SMTP(user=username,password=password,host=host,port=port,smtp_ssl=True)


#to = "1214504186@qq.com"
to = ["收件人QQ账号@qq.com","收件人QQ账号2@qq.com"]
cc = ["抄送人QQ账号@qq.com",username,"1581753566@qq.com"]
subject = "标题"
content = "内容"
attachments = ["Python自动化测试\课程代码/day8/sendemail.py","Python自动化测试\课程代码/day8/上周作业.py"]

mail.send(to=to,cc=cc,subject=subject,contents=content,attachments=attachments)

 

posted @ 2021-11-11 14:14  宝葫芦儿  阅读(93)  评论(0编辑  收藏  举报