#!/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的更多相关文章

  1. Try to write a script to send e-mail but failed

    #-*-coding: utf-8 -*- '''使用Python去发送邮件但是不成功,运行后,等待一段时间, 返回[Errno 10060] A connection attempt failed ...

  2. python auto send email

    /*************************************************************************** * python auto send emai ...

  3. Send Email in Robot Framework Python Using Gmail

    转载自:http://seleniummaster.com/sitecontent/index.php/selenium-robot-framework-menu/selenium-robot-fra ...

  4. [Python] 发送email的几种方式

    python发送email还是比較简单的,能够通过登录邮件服务来发送,linux下也能够使用调用sendmail命令来发送,还能够使用本地或者是远程的smtp服务来发送邮件,无论是单个,群发,还是抄送 ...

  5. python操作email

    python操作email 参考链接: python官网imaplib: https://docs.python.org/2/library/imaplib.html Python 用IMAP接收邮件 ...

  6. 通过 python 处理 email - Email via Python

    Email via Python 1 MIME - Multipurpose Internet Mail Extensions SMTP - Simple Message Transport Prot ...

  7. Python 发送 email 的两种方式

    Python发送email的两种方式,分别为使用登录邮件服务器.调用sendmail命令来发送三种方法 Python发送email比较简单,可以通过登录邮件服务来发送,linux下也可以使用调用sen ...

  8. 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 ...

  9. 使用python调用email模块发送邮件附件

    使用python调用email模块实现附件发送 需要模块: import datetime import time import sys import mimetypes import smtplib ...

随机推荐

  1. 《Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks》论文笔记

    Code Address:https://github.com/junyanz/CycleGAN. Abstract 引出Image Translating的概念(greyscale to color ...

  2. PHP小函数集-篇一

    一. 验证 /** * 判断用户名是否规范 */ function is_username($username) { if (preg_match("/^[a-zA-Z]{1}([0-9a- ...

  3. Linux下安装Redis及搭建主从

    Linux下安装Redis 首先在官网下载对应版本的redis包,这里本人使用的是redis-4.0.8.tar.gz.   然后在服务器中存放redis包的路径下执行tar –vxf redis-4 ...

  4. appium封装显示等待Wait类和ExpectedCondition接口

    此文已由作者夏鹏授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 使用WebDriver做Web自动化的时候,org.openqa.selenium.support.ui中提供 ...

  5. spoj 371 Boxes【最小费用最大流】

    对于ai==0连接(i,t,1,0),对于ai>1(s,i,ai-1,0),然后对以相邻的两个点(i,j)连接(i,j,inf,1),注意这里是一个环的形式,所以1和n+1相连 #include ...

  6. java-通过反射获取目标类的属性,方法,构造器

    首先定义一个urse package com.studay_fanshe; public class User { private String uname; private int age; pri ...

  7. Luogu P1195/P1892 口袋的天空/BOI团伙 【最小生成树/并查集】By cellur925

    其实这俩题挺水的,团伙拿下了一血,但是感觉还是写一下博客比较好x. 一.团伙 题目描述 1920年的芝加哥,出现了一群强盗.如果两个强盗遇上了,那么他们要么是朋友,要么是敌人.而且有一点是肯定的,就是 ...

  8. poj 2506 Tiling 递推

    题目链接: http://poj.org/problem?id=2506 题目描述: 有2*1和2*2两种瓷片,问铺成2*n的图形有多少种方法? 解题思路: 利用递推思想,2*n可以由2*(n-1)的 ...

  9. 二进制流BinaryFormatter存储读取数据的细节测试

    二进制流的使用很方便,为了更好的理解应用它,我创建简单对象开始测试它的增加特性和减少特性. [Serializable] class Data----------开始时候的存储对象 { public ...

  10. [BUG]Dreamweaver6做网页的一个图片文字不清晰的问题

    自己用Dreamweaver6做一个网页,使用PS做图片,为了节约下载流量,我把图片裁剪为GIF格式,通过系统自带的图片浏览器和美图看看,图片上的文字都是清晰的. 我把图片加载进入DW中后,在DW界面 ...