python3发送邮件(yagmail)
# coding:utf-8
import yagmail
# 链接邮箱服务器
yag = yagmail.SMTP(user="xxx@xx.com", password="xxx!!", host='smtp.xxx.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(['xxx@xx.com', 'xxxxxx@xx.com'], '发送附件', contents, ['test.html', 'logo.jpg', 'yagmal_test.txt'])
#抄送
# 邮箱正文 文本及附件
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', '测试邮件', 'test.html', 'logo.jpg',
'yagmal_test.txt']
# 发送邮件
yag.send(to='xx@xx.com', cc='xxx@xxx.com', subject='发送附件', contents=contents)
posted on 2017-12-19 17:01 sammy1989 阅读(1749) 评论(0) 编辑 收藏 举报