yagmail 实现发邮件

yagmail 可以更简单的来实现自动发邮件功能。

github项目地址: https://github.com/kootenpv/yagmail

安装

pip install yagmail

简单例子

import yagmail

#链接邮箱服务器
yag = yagmail.SMTP( user="[email protected]", password="1234", host='smtp.126.com')

# 邮箱正文
contents = ['This is the body, and here is just text http://somedomain/image.png',
            'You can find an audio file attached.', '/local/path/song.mp3']

# 发送邮件
yag.send('[email protected]', 'subject', contents)

给多个用户发送邮件

# 发送邮件
yag.send(['[email protected]','[email protected]','[email protected]'], 'subject', contents)

只需要将接收邮箱 变成一个list即可。

发送带附件的邮件

# 发送邮件
yag.send('[email protected]', '发送附件', contents, ["d://log.txt","d://baidu_img.jpg"])

【python】yagmail 实现发邮件

相关文章:

  • 2021-06-12
  • 2021-11-21
  • 2021-11-13
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2022-02-19
相关资源
相似解决方案