python实发邮件实例详解

yipeiwu_com6年前Python基础

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 /zb_users/upload/202003/lsixxpdko4t.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"])

以上就是本次介绍的关于python实发邮件的全部相关内容,感谢大家的学习和对【听图阁-专注于Python设计】的支持。

相关文章

python调用摄像头显示图像的实例

如下所示: import cv2 import numpy as np bins = np.arange(256).reshape(256,1) def hist_curve(i...

python中将阿拉伯数字转换成中文的实现代码

复制代码 代码如下: #!/usr/bin/python #-*- encoding: utf-8 -*- import types class NotIntegerError(Exce...

python安装scipy的方法步骤

python安装scipy的方法步骤

Scipy高级科学计算库:和Numpy联系很密切,Scipy一般都是操控Numpy数组来进行科学计算、统计分析,所以可以说是基于Numpy之上了。 Scipy库的安装 pip ins...

使用python实现滑动验证码功能

使用python实现滑动验证码功能

首先安装一个需要用到的模块 pip install social-auth-app-django 安装完后在终端输入pip list会看到 social-auth-app-djang...

Python中使用md5sum检查目录中相同文件代码分享

复制代码 代码如下: """This module contains code from Think Python by Allen B. Downey http://thinkpyth...