yagmail发送邮件只需要3行代码就可以搞定,首先安装yagmail:pip install yagmail

demo如下:

#  todo 导入邮件服务器
import yagmail

sender = '148908761@qq.com'     # 发送人邮箱账号
password = 'ersbmrvcnscebab'    # 发送人邮箱授权码,而不是邮箱密码
res = '1858123247@163.com'      # 收件人邮箱账号

yag = yagmail.SMTP(user=sender, password=password, host='smtp.qq.com', smtp_ssl=True)
content = r'D:\file\Report\test_2019_09_10_23_03_17_834.html'
yag.send(to=res, subject='测试报告', contents=content)

运行报错:SMTPAuthenticationError解决方法:https://blog.csdn.net/qq_39241986/article/details/81349270

获取邮箱授权码:https://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
  • 2021-12-27
  • 2021-12-14
  • 2022-12-23
  • 2021-10-29
  • 2022-01-02
猜你喜欢
  • 2021-09-27
  • 2021-08-19
  • 2021-06-01
  • 2022-12-23
  • 2022-02-19
  • 2021-06-12
  • 2021-12-02
相关资源
相似解决方案