python实发邮件实例详解

python实发邮件实例详解,第1张

python实发邮件实例详解

yagmail 实现发邮件

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

1、安装

pip install yagmail

2、简单举例

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)

3、给多个用户发送邮件

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

4、发送带附件邮件

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

以上就是本次介绍的关于python实发邮件的全部相关内容,感谢大家的学习和对考高分网的支持。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/3250565.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-10-04
下一篇 2022-10-04

发表评论

登录后才能评论

评论列表(0条)

保存