yagmail发送附件

效果图:

在这里插入图片描述

经测试代码:

# 导入yagmail第三方库
import yagmail

# yagmail.SMTP(user="邮箱名",host="SMTP服务器域名")
yag = yagmail.SMTP(user="[email protected]", host="smtp.qq.com")
# 正文内容
contents = ["当年万里觅封侯。", "匹马戍梁州。",
            "关河梦断何处,", "尘暗旧貂裘。",
            ]
attachment = [r"C:\\Users\TYC\Desktop\1.jfif", r"C:\\Users\TYC\Desktop\2.txt", r"C:\\Users\TYC\Desktop\3.docx"]
subject = "诉衷情·当年万里觅封侯"
# 发送邮件 yag.send("收件人",邮件标题,邮件内容)
yag.send("[email protected]", subject, contents, attachment)
yag.close()
print("发送成功")

猜你喜欢

转载自blog.csdn.net/weixin_51424938/article/details/113777233
今日推荐