来源链接
1. 邮件发送yagmail
import yagmail
# gbk使发送的附件在windows电脑上不会出现乱码
yag = yagmail.SMTP(user="EmailAddr", password="EmailPassword", host="SendServer", encoding="gbk")
contents = [
'This is the body, and here is just text',
'<img src="https://wx2.sinaimg.cn/lllljpg" alt="">', # 邮件内容嵌入图片
'You can find an audio file attached.',
"./file.xlsx" # 字符串对应了一个文件,会成为邮件的附件,如果找不到文件,就是一个普通的字符串
]
yag.send('111111111@qq.com', 'subject', contents)