yagmail自动发邮件

#服务器地址
host="smtp.163.com"
#邮箱账号
user="17@163.com"
#密码
passowrd="邮箱授权码"
#邮箱内容
contents=["这里是正文"]
#链接邮箱服务器
yaml = yagmail.SMTP(host=host, user=user, password=password)
#邮箱正文
contents =contents
#发送邮件 to:发送给谁,如果要发送给多个人就用list[账号1,账号2,账号n],subject:邮件的标题,cc:抄送给谁,attachments:附件
yaml.send(to="12@qq.com", subject="这是测试邮件,请忽略", cc="1761@163.com", attachments="info.txt")
#关闭邮箱
yaml.close()
原文地址:https://www.cnblogs.com/zhangwei-qianqian/p/14030929.html