美文网首页
三行代码发送带附件邮件

三行代码发送带附件邮件

作者: 6c0fe9142f09 | 来源:发表于2018-06-28 14:13 被阅读6次

demo

pip install yagmail
import yagmail
def emailWithFile(bodyText,sendFileName):
    # qq邮箱的邮件发送需要获取SMTP密码,使用qq密码是不行的
    yag = yagmail.SMTP(user='565506019@qq.com', password='passwd', host='smtp.qq.com', port='465')
    body = u""+bodyText
    yag.send(to='565506019@qq.com', subject="环球财经-"+bodyText, contents=[body, sendFileName])

运行结果

emailWithFile("180621","····/yangshicaijing180621.aac")

参考文章

https://www.jianshu.com/p/3d1f6cc65630?from=singlemessage

相关文章

网友评论

      本文标题:三行代码发送带附件邮件

      本文链接:https://www.haomeiwen.com/subject/gmugyftx.html