yagmail模块的使用

import yagmail

# 链接邮箱服务器
yag = yagmail.SMTP(user="xxxxxx@126.com", password="xxxxxx", host='smtp.126.com')

# 邮箱正文
contents = ['This is the body, and here is just text http://somedomain/image.png',
'You can find an audio file attached.', '/local/path/song.mp3']

# 发送邮件
yag.send('389688559@qq.com', 'subject', contents) # 收件人 邮件标题 邮件内容

yag.send(['aa@126.com', 'bb@qq.com', 'cc@gmail.com'], 'subject', contents) # 多个用户

yag.send('aaaa@126.com', '发送附件', contents, ["d://log.txt", "d://baidu_img.jpg"]) # 发送附件
posted @ 2018-04-05 13:49  王思磊  阅读(240)  评论(0编辑  收藏  举报