用python SMTP进行邮件发送
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
"""多用户及带附件发送邮件代码""" smtpserver = 'smtp.163.com' #发送邮箱服务器 user = '***@163.com'
password = '密码' sender = 'a5974939632@163.com'
receive = ['接收邮箱1', '接收邮箱2'] subject = 'Web Selenium 自动化测试报告'
content = '<html><h1 style="color:red">我要自学网,自学成才!</h1></html>' send_file = open(r'E:\study\SeleniumPython\UnitTest\Test_Baidu\test_report\2019-01-08 12_00_24result.html','rb').read() att = MIMEText(send_file, 'base64', 'utf-8')
att['Content-Type'] = 'application/octet-stream'
att['Content-Disposition'] = 'attachment:filename="2019-01-08 12_00_24result.html"' msgRoot = MIMEMultipart()
msgRoot.attach(MIMEText(content, 'html', 'utf-8'))
msgRoot['Subject'] = subject
msgRoot['From'] = sender
msgRoot['To'] = ','.join(receive)
msgRoot.attach(att) smtp = smtplib.SMTP_SSL(smtpserver,465)
smtp.helo(smtpserver)
smtp.ehlo(smtpserver)
smtp.login(user,password) print("start send Email...")
smtp.sendmail(sender,receive,msgRoot.as_string())
smtp.quit()
print("send email end!")
用python SMTP进行邮件发送的更多相关文章
- python自动化之邮件发送
#!/usr/bin/env python # -*- coding:utf-8 -*- import smtplib from email.mime.multipart import MIMEMul ...
- python smtp 发邮件 添加附件
# -*- coding:utf-8 -*- # __author__ = 'justing' import os import smtplib from email.mime.multipart i ...
- python SMTP发邮件
# from email.mime.text import MIMEText from email.header import Header import smtplib # sender = 'zc ...
- Selenium+Python之163邮件发送
今晚写了一个163邮箱登录的脚本,由于不停的访问163登录主页导致直接访问163邮箱主页登录需要输入验证码,因为无法获取到验证码,就这导致直接访问主页登录脚本不可行,为了绕过验证码,现在先访问hao1 ...
- smtp outlook邮件发送非授权码模式
1.起因:send fail SMTP AUTH extension not supported by server. 使用端口25 和587均失效出现此问题 首先前往outlook修改设置pop和I ...
- python smtp发邮件报错“[Errno -2] Name or service not known”的解决
最近给ss-py-mu写了个检查用户是否到期,并在到期前的第2天邮件提醒的功能. 配置存储在ini文件中,通过configparser模块获取,但尝试发送邮件的时候发现报错[Errno -2] Nam ...
- python SMTP邮件发送(转载)
Python SMTP发送邮件 SMTP(Simple Mail Transfer Protocol)即简单邮件传输协议,它是一组用于由源地址到目的地址传送邮件的规则,由它来控制信件的中转方式. py ...
- JavaUtil smtp 邮件发送
需要用到的jar包:javax.mail.jar package com.lee.util; import java.io.UnsupportedEncodingException; import j ...
- SMTP协议及POP3协议-邮件发送和接收原理(转)
本文转自https://blog.csdn.net/qq_15646957/article/details/52544099 感谢作者 一. 邮件开发涉及到的一些基本概念 1.1.邮件服务器和电子邮箱 ...
随机推荐
- centos上nginx的安装
安装步骤: 1.下载nginx,执行:wget http://nginx.org/download/nginx-1.10.2.tar.gz 2.解压,执行:tar vxzf nginx-1.10. ...
- 推荐一个配置linux服务的网站
该网站的各种linux服务的配置都是基于CentOS系统的 基本上各种linux服务都有了 http://www.server-world.info/en/
- SDOI2018 一轮培训划水祭
\(\mathcal{Day \ \ -3}\) 作为前言来讲,我对于过几天的省选培训还是很期待的--就算我的实力根本不够,名额是学校推荐的,但是能见到\(\mathcal{cwbc}\)以及一众大佬 ...
- 404 Note Found 队-课堂实战-项目UML设计
目录 团队信息 分工选择 课上分工 课下分工 ToDolist alpha版本要做的事情 燃尽图 UML 用例图 状态图 活动图 类图 部署图 实例图 对象图 时序图 包图 通信图 贡献分评定 课上贡 ...
- java alibaba fastJson 遍历数组json
import java.util.*; import com.alibaba.fastjson.*; public class Test { public static void main(Strin ...
- Docker 常用命令——容器
1.新建并启动容器 docker run [option] images [command][arg] #根据镜像新建容器并运行.如果本地没有镜像则从docker hub上拉取. --name ...
- Oracle数据库对表基本的操作--增删查改
--向student表中加入入学时间属性,其数据类型为日期型alter table student add scome date; --删除student表中的入学时间属性alter table st ...
- iOS 类似微博或朋友圈的信息流
1.先上图: image.png image.png 因为做过了好几次这样的需求,所以这次想到把它拿出来,下次再需要做的时候直接拿过来改改就能用了,节约时间. 2.功能 文字收起和展开,行高自 ...
- MySQL 日常运维业务账号权限的控制
在MySQL数据库日常运维中,对业务子账号的权限的统一控制十分必要. 业务上基本分为读账号和写账号两种账号,所以可以整理为固定的存储过程,让数据库自动生成对应的库的账号,随机密码.以及统一的读权限,写 ...
- 【项目笔记】完成一个基于SSM框架的增删改查的模块后总结的问题
最近为了准备新工作重新摸出了SSM框架,同时从0学习了JQuery,终于用一周做完了一个包括增删改查的模块(主要是属性太多了,其中一个类50+,复制粘贴耗时). 从中特意记下了几个遇到的问题,总结一下 ...