python邮件发送自动化测试报告
话不多说直接贴代码
# encoding: utf-8
import smtplib #发送邮件模块
from email.mime.text import MIMEText #邮件内容
from email.header import Header def send_email(new_reportfile):
"""发送邮件"""
f = open(new_reportfile,'rb')
mail_content = f.read()
f.close() # 发送邮箱服务器
smtpserver = 'smtp.163.com' # 用户名密码
user = 'ye_songqiao123@163.com'
password = '你的密码or授权码' # 发送和接收邮箱用户
sender = 'ye_songqiao123@163.com'
receiver = '719584032@qq.com'
# 发送给多人
# receiver = ['123@qq.com','23432@qq.com','719584032@qq.com'] # 定义标题和内容
biaoti = "YT API 自动化测试报告" # HTML邮件正文
msg = MIMEText(mail_content, 'html', 'utf-8')
msg['subject'] = Header(biaoti, 'utf-8')
msg['from'] = sender
msg['to'] = receiver
# 发送给多人,已逗号为分隔符,针对receiver这个变量
# msg['to'] =','.join(receiver) # SSL协议端口号要使用465
smtp = smtplib.SMTP_SSL(smtpserver, 465) # HELO 像服务器标识用户身份
smtp.helo(smtpserver) # 服务器返回结果确认
smtp.ehlo(smtpserver) # 登陆用户
smtp.login(user, password)
print("开始发送邮件.............")
smtp.sendmail(sender, receiver, msg.as_string())
smtp.quit()
print("邮件发送完成.....................") if __name__ == '__main__':
path = 'E:\\testreport\\YTtest.html'
send_email(path)
python邮件发送自动化测试报告的更多相关文章
- centos 7 keepalived故障邮件通知实战(附Python邮件发送脚本)
centos 7 keepalived故障邮件通知实战(附Python邮件发送脚本) ##################### sendmail.py begin ######## ...
- python之邮件发送自动化
# -*- coding:utf-8 -*-#@Time : 2020/3/24 22:55#@Autor: Mr.White#@File : 发送邮件.py 一.导入所需要的类 import smt ...
- Python 邮件发送
python发送各类邮件的主要方法 python中email模块使得处理邮件变得比较简单,今天着重学习了一下发送邮件的具体做法,这里写写自己的的心得,也请高手给些指点. 一.相关模块介绍 ...
- Python邮件发送脚本(Linux,Windows)通用
脚本 #!/usr/bin/python #-*- coding:utf-8 -*- #Python Mail for chenglee #if fileformat=dos, update file ...
- python邮件发送脚本
转自:http://phinecos.cnblogs.com/ #!/usr/bin/python #coding=utf-8 #@author:dengyike #@date:2010-09-28 ...
- python邮件发送
'''qq邮件与其他邮件有所不同,下以我的qq邮件为例(切勿转载):''' import osimport smtplibfrom email.mime.text import MIMEText # ...
- Python邮件发送源码
-- coding:utf-8 -- i = 0 while i < 10: #发送十次 import smtplib from email.mime.text import MIMEText ...
- Python+Selenium框架 ---自动化测试报告的生成
本文来介绍如何生成自动化测试报告,前面文章尾部提到了利用HTMLTestRunner.py来生成自动化测试报告.关于HTMLTestRunner不过多介绍,只需要知道是一个能生成一个HTML格式的网页 ...
- python生成接口自动化测试报告模版
1:准备html模版 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> &l ...
随机推荐
- HTML怎么块外横向剧中
HTML 块外横向剧中 在HTML中有一个块外横向剧中的代码 那就是margin:0 auto 这个能是块内元素横向剧中 剧中前: 剧中后
- 九.配置SMB共享(Samba共享)
• Samba 软件项目 – 用途:为客户机提供共享使用的文件夹 – 协议:SMB(TCP 139).CIFS(TCP 445) • 所需软件包:samba • 系统服务:smb 管理共享账号 ...
- [转]CentOS 7安装Python3.6过程(让linux系统共存Python2和Python3环境)
CentOS 7系统自带了python2,不过可以不用2版本,直接使用python3运行python脚本就可以,但是千万别去动系统自带的python2,因为有程序依赖目前的python2环境,比如yu ...
- NetworkX系列教程(5)-查看graph的信息
小书匠Graph图论 有时候graph建好后,我们并不清除该graph内节点的,边的信息,这就需要调用函数去查看了. 目录: 6.查看Graph的信息 6.1查看graph内节点,边的 6.2查看gr ...
- 一些scala的操作
Scala获取当前目录下所有文件 import java.io.File //获取目录下的所有文件,当前项目目录输入new File(".") def getFiles1(dir: ...
- 2019 ICPC 沈阳网络赛 J. Ghh Matin
Problem Similar to the strange ability of Martin (the hero of Martin Martin), Ghh will random occurr ...
- Java基础系列 - 查找数组的最大值和最小值
package com.test6; public class test5 { public static void main(String[] args) { int[] arr = {1, 2, ...
- 如何判断Linux下 网卡是虚拟还是物理网卡?
ifconfig命令可以查看Linux系统中正在使用的网卡,包括物理网卡和虚拟网卡,如果想要查看Linux系统中全部的网卡,可以查看/proc/net/dev文件,那如何区分网卡是虚拟还是物理的呢? ...
- 通俗易懂的Redis数据结构基础教程
Redis有5个基本数据结构,string.list.hash.set和zset.它们是日常开发中使用频率非常高应用最为广泛的数据结构,把这5个数据结构都吃透了,你就掌握了Redis应用知识的一半了. ...
- Leetcode题 257. Binary Tree Paths
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 ...