Python Send Mail Yagmail

2019-02-04

本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。

声明: 本博客欢迎转发,但请保留原作者信息!
github地址:atanx
新浪微博:@蜀山掌门V
QQ:365039667
博客地址:江斌的博客
内容仅供学习参考,如有不当引用,请告知博主。

layout: post title: Python-使用yagmail发送邮件 description: Python-使用yagmail发送邮件 category: 技术 —

安装yagmail

pip install yagmail

使用

如果报错SSL,可以使用smtp_ssl=False关闭ssl。

# coding=utf-8
import yagmail 

yag = yagmail.SMTP(user='07jiangbin@163.com', password='woshi110.', host='smtp.163.com', port='25', smtp_ssl=False)
body = u"老师,你好!\n <div style='color:red'>注意</div>这是最近工作的文件,请查收。"

yag.send(to='07jiangbin@163.com', subject=u'工作文件', contents=[body], attachments=['setup.py'])
print(u"已发送邮件")



章节列表