先pip install yagmail
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 简单发邮件的实例
import yagmail # 1.引入包
sender = '111111111@qq.com' # 发件人
password = 'prhfjasjktmba' # 密钥
receiver = '222222222@qq.com' # 收件人
yag = yagmail.SMTP(user=sender, password=password, host='smtp.qq.com', smtp_ssl=True)
contents = '我发了封邮件!'
yag.send(to=receiver, subject='标题', contents=contents)
print('发送成功')
python邮件
https://www.1owo.com/python/python/python-python%E5%8F%91%E9%82%AE%E4%BB%B6/