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://img.haomeiwen.com/i2572206/eb2c2477e37849e3.png)
参考文章
网友评论