import yagmail
if __name__ == '__main__':
yag = yagmail.SMTP(user="user1@163.com", password="user1password", host='smtp.163.com')
contents = ['This is the body, and here is just text https://zhuanlan.zhihu.com/python2018',
'You can find an file attached.', '/tmp/sample.png']
yag.send(to='user2@hotmail.com',
subject='yagmail sample',
contents=contents)
本系列文章和代码已经作为项目归档到github,仓库地址:jumper2014/PyCodeComplete。大家觉得有帮助就请在github上star一下,你的支持是我更新的动力。什么?你没有github账号?学习Python怎么可以没有github账号呢,快去注册一个啦!