yagmail邮件发送
·
import yagmail
yag = yagmail.SMTP(user='cts618@126.com', password='', host='smtp.126.com', port=465)
# 设置 preview_only=True,邮件不会真正发送
result = yag.send(
to="cts619@126.com",
subject='yagmail发送测试',
contents='<h1>这是第二封测试邮件17:55</h1>\nsecond line'.replace('\r','').replace('\n',''),
preview_only=True # 关键参数在这里
)
# result 里包含了完整的邮件内容,你可以打印出来检查
print(result)
with open('a.eml','w')as f:
f.write(result[1])
yag.close()
更多推荐

所有评论(0)