#!/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. 从free到page cache

    Free 我们经常用free查看服务器的内存使用情况,而free中的输出却有些让人困惑,如下:   图1-1 先看看各个数字的意义以及如何计算得到: free命令输出的第二行(Mem):这行分别显示了 ...

  2. css3 vw -----解决页面滚动出现跳动的bug

    100vw相对于浏览器的window.innerWidth,是浏览器的内部宽度,注意,滚动条宽度也计算在内!而100%是可用宽度,是不含滚动条的宽度. demo: h1{font-size:8vw;} ...

  3. angular中transclude的理解

    今天被这个transclude搞糊涂了,弄了半天,才知道原来使用起来很简单.很烦恼为社么书中的对于这个的介绍这么晦涩难懂.直到看到了这篇文章,才让我弄清楚了. 一.transclude介绍 trans ...

  4. iOS SDK更新换代的功能

    wantsFullScreenLayout已经作废了,取而代之是 1.edgesForExtendedLayout 这个属性是UIExtendedEdge类型,用来制定视图的哪条边需要扩展.比如UIR ...

  5. java-异常简介

    1.简介 ############################################################### ############################### ...

  6. mysql主从同步异常原因及恢复

    mysql主从同步异常原因及恢复 前言 mysql数据库做主从复制,不仅可以为数据库的数据做实时备份,保证数据的完整性,还能做为读写分离,提升数据库的整体性能.但是,mysql主从复制经常会因为某些原 ...

  7. Guilty Prince LightOJ - 1012

    Guilty Prince LightOJ - 1012 #include<cstdio> #include<cstring> ][]; int ans,h,w,T,TT; ] ...

  8. 升序 Collections.sort(list) 降序 Collections.reserve(list) 随机 Collections.shuffle(list)

    package Day28ketangzuoye; import java.util.ArrayList; import java.util.Collections; import java.util ...

  9. glassfish应用服务器安装配置

    1.Glassfish4.0下载地址:https://glassfish.java.net/download.html#gfoseTab 2.将下载的glassfish-4.0.zip传输到服务器/h ...

  10. 转 Docker Swarm vs Kubernetes

    容器化已经改变我们部署软件和微服务开发的方式.如果你刚听说容器, 这篇博客帮你入门. 什么是容器编排 容器能够把服务打包成基本单元,你可以把它部署到任何地方:本地机器.测试环境或者生产系统.但是在生产 ...