python send email
#!/usr/bin/python
# -*- coding: UTF-8 -*- # coding:utf8
from smtplib import SMTP_SSL
from email.header import Header
from email.mime.text import MIMEText mail_info = {
"from": "vickeywu557@gmail.com",
"to": "vickeywu557@gmail.com",
"hostname": "smtp.gmail.com",
"username": "vickeywu557@gmail.com",
"password": "",
"mail_subject": "test",
"mail_text": "hello, this is a test email, sended by py",
"mail_encoding": "utf-8"
} if __name__ == '__main__':
# 这里使用SMTP_SSL就是默认使用465端口
smtp = SMTP_SSL(mail_info["hostname"])
smtp.set_debuglevel(1) smtp.ehlo(mail_info["hostname"]) smtp.login(mail_info["username"], mail_info["password"]) msg = MIMEText(mail_info["mail_text"], "plain", mail_info["mail_encoding"])
msg["Subject"] = Header(mail_info["mail_subject"], mail_info["mail_encoding"])
msg["from"] = mail_info["from"]
msg["to"] = mail_info["to"] smtp.sendmail(mail_info["from"], mail_info["to"], msg.as_string()) smtp.quit()
参考【https://www.cnblogs.com/inva/p/5115794.html】
python send email的更多相关文章
- Try to write a script to send e-mail but failed
#-*-coding: utf-8 -*- '''使用Python去发送邮件但是不成功,运行后,等待一段时间, 返回[Errno 10060] A connection attempt failed ...
- python auto send email
/*************************************************************************** * python auto send emai ...
- Send Email in Robot Framework Python Using Gmail
转载自:http://seleniummaster.com/sitecontent/index.php/selenium-robot-framework-menu/selenium-robot-fra ...
- [Python] 发送email的几种方式
python发送email还是比較简单的,能够通过登录邮件服务来发送,linux下也能够使用调用sendmail命令来发送,还能够使用本地或者是远程的smtp服务来发送邮件,无论是单个,群发,还是抄送 ...
- python操作email
python操作email 参考链接: python官网imaplib: https://docs.python.org/2/library/imaplib.html Python 用IMAP接收邮件 ...
- 通过 python 处理 email - Email via Python
Email via Python 1 MIME - Multipurpose Internet Mail Extensions SMTP - Simple Message Transport Prot ...
- Python 发送 email 的两种方式
Python发送email的两种方式,分别为使用登录邮件服务器.调用sendmail命令来发送三种方法 Python发送email比较简单,可以通过登录邮件服务来发送,linux下也可以使用调用sen ...
- Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email
Check SMTP Server Availability for ORA-29278 or ORA-29279 errors using UTL_SMTP to Send Email. (文档 I ...
- 使用python调用email模块发送邮件附件
使用python调用email模块实现附件发送 需要模块: import datetime import time import sys import mimetypes import smtplib ...
随机推荐
- 洛谷P2943 清理——DP
题目:https://www.luogu.org/problemnew/show/P2943 一眼看去就有个 n^2 的做法:f[i] = min{ f[j] + num( i - j ) * num ...
- 《JAVA与模式》之解释器模式
解释器模式是类的行为模式.给定一个语言之后,解释器模式可以定义出其文法的一种表示,并同时提供一个解释器.客户端可以使用这个解释器来解释这个语言中的句子. 解释器模式的结构 下面就以一个示意性的系统为例 ...
- 2015年北京网赛 boxes(bfs)
题目链接: http://hihocoder.com/problemset/problem/1233 题目描述: 给定最多七个箱子,每个箱子的重量都不相同,每次都可以将一个箱子放在相邻的位置上,如果相 ...
- 【position】
background-position 定位的position的区别 background-position 相对的位置是(容器的宽度-子元素的宽度) 当子元素的宽度大于容器的宽度 backgroun ...
- COLORREF
COLORREF含义及在VC++中的使用 转载 原创 2016年03月11日 23:40:19 4019 所谓真彩色是指显示出来的图像的颜色与真实世界中的颜色非常自然逼真,使得人眼难以区分它们之间的差 ...
- springMVC访问根路径问题
当web.xml没有配置欢迎页:如下 <welcome-file-list> <welcome-file>login.jsp</welcome-file> < ...
- 使用root用户登录到AWS EC2服务器,上传文件到/var/www目录
关键词 1.aws ec2中上传文件到/var/www目录(使用filezilla) 2.使用root用户登录aws ec2实例 上一篇随笔中记录了在aws ec2实例中部署apache服务器的过程, ...
- javascript使用正则表达式,从字符串提取内容,多数组解析
JavaScript有两种方式创建一个正则表达式: 第一种方式是直接通过/正则表达式/写出来,第二种方式是通过new RegExp('正则表达式')创建一个RegExp对象. 如: var re1 = ...
- 【SpringCloud构建微服务系列】微服务网关Zuul
一.为什么要用微服务网关 在微服务架构中,一般不同的微服务有不同的网络地址,而外部客户端(如手机APP)可能需要调用多个接口才能完成一次业务需求.例如一个电影购票的手机APP,可能会调用多个微服务的接 ...
- Unix\Linux | 总结笔记 |文件系统_shell重定向
输入重定向< 从文件中获得命令需要的输入数据,适合数据源已经定义好,可重复使用 #显示文件test.txt的内容 cat < tesxt.txt #统计文件test.txt中的行数 单词数 ...