import smtplib
from email.header import Header
from email.mime.text import MIMEText from_addr = 'XXX@163.com' #发送邮箱的地址
password = 'XXXXXX' #发送邮箱的客户端登陆密码,可能和网页登陆密码不同,需要单独设置 smtp_server = 'smtp.163.com'
to_addr = 'XXX@foxmail.com' #接收邮箱地址 msg = MIMEText('hello, send by Python...', 'plain', 'utf-8')
msg['From'] = 'XXX@163.com' #发送邮箱地址
msg['Subject'] = Header(u'text', 'utf8').encode() #邮件主题
server = smtplib.SMTP(smtp_server, 25) #连接SMTP服务器
server.login(from_addr, password) #登陆
server.sendmail(from_addr, [to_addr], msg.as_string()) #发送
server.quit()

  

python 邮件发送 脚本的更多相关文章

  1. centos 7 keepalived故障邮件通知实战(附Python邮件发送脚本)

    centos 7 keepalived故障邮件通知实战(附Python邮件发送脚本) #####################     sendmail.py  begin     ######## ...

  2. Python邮件发送脚本(Linux,Windows)通用

    脚本 #!/usr/bin/python #-*- coding:utf-8 -*- #Python Mail for chenglee #if fileformat=dos, update file ...

  3. python邮件发送脚本

    转自:http://phinecos.cnblogs.com/ #!/usr/bin/python #coding=utf-8 #@author:dengyike #@date:2010-09-28 ...

  4. Python 邮件发送

    python发送各类邮件的主要方法   python中email模块使得处理邮件变得比较简单,今天着重学习了一下发送邮件的具体做法,这里写写自己的的心得,也请高手给些指点.     一.相关模块介绍 ...

  5. python邮件发送

    '''qq邮件与其他邮件有所不同,下以我的qq邮件为例(切勿转载):''' import osimport smtplibfrom email.mime.text import MIMEText # ...

  6. Python邮件发送源码

    -- coding:utf-8 -- i = 0 while i < 10: #发送十次 import smtplib from email.mime.text import MIMEText ...

  7. python邮件发送自动化测试报告

    话不多说直接贴代码 # encoding: utf-8import smtplib #发送邮件模块from email.mime.text import MIMEText #邮件内容from emai ...

  8. python邮件发送:普通文本、html、添加附件

    # -*- coding: utf-8 -*- # @Time : 2019/9/19 13:46 # @Author : HuangWenjun # @Email : 350920551@qq.co ...

  9. 一个python的邮件发送脚本,自动,定时,可以附件发送,抄送,附有说明文件

    #!/bin/env python # -*- coding: utf-8 -*- import datetime import smtplib import os,sys from email.mi ...

随机推荐

  1. Flask and uWSGI - unable to load app 0 (mountpoint='') (callable not found or import error)

    Here is my directory structure: -/path/to/folder/run.py -|app -|__init__.py -|views.py -|templates - ...

  2. mybatis mapper association collection

    1.Question Description: sometimes, POJO bean contains another bean or collection as property, it's s ...

  3. 【Android】Android SDK Manager更新慢/失败的问题

    前言:更新下载Intel x86 Atom_64 System Image的时候总是失败,速度只有几KB,我这是10M的网啊. 最后找到一篇日志,解决了这个问题.非常感谢!其参考地址:http://w ...

  4. [ERROR] Plugin 'InnoDB' init function returned error

    今天一大早到公司,计划把开发环境的mysql升级到5.7.15,干净关闭系统后,把目录从5.6指向到5.7,一切正常,重新指向5.6启动时,报下列错误: 2016-10-31 08:13:14 869 ...

  5. [ASP.NET MVC] 使用Bootsnipp样式

    [ASP.NET MVC] 使用Bootsnipp样式 前言 在「[ASP.NET MVC] 使用Bootstrap套件」这篇文章中,介绍了如何在Web项目里使用Bootstrap套件,让用户界面更加 ...

  6. DOM解析XML文件

    1.首先把第三方代码拖进工程 GDataXMLNode.h和GDataXMLNode.m这两个文件放进工程里面 2.引入libxml2库文件 3.将GDataXMLNode.h文件中的这两个东西在工程 ...

  7. OC中的内存问题

    常见的内存问题有以下几种: 1.野指针异常:访问没有所有权的内存,如果想要安全的访问,必须确保空间还在 2.内存泄露:空间使用完之后没有及时释放 3.过度释放:对同一块存储空间释放多次,立刻crash ...

  8. iOS开发Facebook POP动效库使用教程

    如果说Origami这款动效原型工具是Facebook Paper的幕后功臣,那么POP便是Origami的地基.感谢Facebook开源了POP动效库,让人人都能制作出华丽的动效.我们只需5步,便能 ...

  9. iOS 准确计算某个时间点距现在的时间差的代码 如"几分钟,几小时,几秒之前" ,

    利用时间戳来进行计算  ,需要给它一个时间: NSString *countTime = [self intervalSinceNow:@"2015-10-29 17:00:00" ...

  10. Silverlight项目笔记7:xml/json数据解析、TreeView、引用类型与数据绑定错误、图片加载、虚拟目录设置、silverlight安全机制引发的问题、WebClient缓存问题

    1.xml/json数据解析 (1)xml数据解析 使用WebClient获取数据,获取到的数据实例化为一个XDocument,使用XDocument的Descendants(XName)方法获得对应 ...