利用yagmail发送电子邮件
1. 安装yagmail
pip install yagmail
2. 使用yagmail
#-*- encoding:utf-8 -*-
import yagmail
yag=yagmail.SMTP(user="xxxxx@126.com",password="xxxxtest",host="smtp.126.com")
concent="hello!"
yag.send(to="test@qq.com",subject="主题test",contents=concent)
上述邮箱密码已经换成无法使用的,请替换后运行,SMTP那一行host不能少,否则报错。
参考资料 1. python自动发邮件库yagmail