python实发邮件实例详解
作者:ZibinChen 时间:2023-10-13 00:43:01
yagmail 实现发邮件
yagmail 可以更简单的来实现自动发邮件功能。
1、安装
pip install yagmail
2、简单举例
import yagmail
#链接邮箱服务器
yag = yagmail.SMTP( user="user@126.com", 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('taaa@126.com', 'subject', contents)
3、给多个用户发送邮件
# 发送邮件
yag.send(['aa@126.com','bb@qq.com','cc@gmail.com'], 'subject', contents)
4、发送带附件邮件
# 发送邮件
yag.send('aaaa@126.com', '发送附件', contents, ["d://log.txt","d://baidu_img.jpg"])
来源:https://www.cnblogs.com/zibinchen/p/11834537.html
标签:python,发邮件
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
轻松处理Dreamweaver段落缩进
2007-11-17 07:53:00
Python实现常见数据格式转换的方法详解
2023-04-16 03:48:16
![](https://img.aspxhome.com/file/2023/0/115880_0s.png)
提高代码可读性的十大注释技巧分享
2023-05-28 21:55:35
python中@property和property函数常见使用方法示例
2021-11-13 03:32:20
mysql SELECT语句去除某个字段的重复信息
2024-01-17 04:15:41
python虚拟机之描述器实现原理与源码分析
2022-05-24 14:41:10
JavaScript初级教程(第五课续)第1/3页
2024-04-17 10:10:07
如何在Python中隐藏和加密密码示例详解
2023-07-19 00:00:09
windows下Idea使用git clone failed. Could not read from remote repository.
2022-06-17 03:13:05
![](https://img.aspxhome.com/file/2023/9/67199_0s.png)
使用Python3 poplib模块删除服务器多天前的邮件实现代码
2023-05-08 08:21:54
![](https://img.aspxhome.com/file/2023/7/107807_0s.png)
python的scipy.stats模块中正态分布常用函数总结
2021-06-26 16:03:04
Python中的sys.stdout.write实现打印刷新功能
2022-01-17 14:51:50
![](https://img.aspxhome.com/file/2023/6/133866_0s.gif)
flask中响应错误的处理及errorhandler的应用方式
2021-09-22 08:46:19
![](https://img.aspxhome.com/file/2023/0/82770_0s.png)
Python操作Redis之设置key的过期时间实例代码
2022-02-11 06:13:05
基于Python搭建人脸识别考勤系统
2021-07-08 10:17:42
![](https://img.aspxhome.com/file/2023/9/78759_0s.jpg)
em和strong的区别
2008-12-23 12:08:00
SQL Server SA权限最新入侵方法
2009-03-25 16:56:00
php购物车实现方法
2023-11-16 22:54:51
javascript 45种缓动效果(一)
2009-09-19 18:30:00
Python学习之虚拟环境原理详解
2023-02-12 16:45:52
![](https://img.aspxhome.com/file/2023/5/118015_0s.jpg)