import smtplib
from operator import itemgetter, attrgetter
from email.mime.text import MIMEText
from email.header import Header
from email.mime.multipart import MIMEMultipart
from email.utils import COMMASPACE,formatdate to = ['wangquanjun@xxx.com']
mail = u'我爱北京天安门' msg = MIMEMultipart()
msg['From'] = 'spider@yq01-ps-exdata-svr00.yq01'
msg['Subject'] = Header('外部数据实时引入小时级监控', 'utf-8')
msg['Date'] = formatdate(localtime=True)
msg['To'] = 'wangquanjun@xxx.com'
msg.attach(MIMEText(mail, _subtype='plain', _charset='utf-8')) server = smtplib.SMTP('xxx-in.xxx.com')
err = server.sendmail('root@yq01-ps-exdata-svr00.yq01', to, msg.as_string())
print err
server.quit() def sendEmail(dic):
    mail = dic2table(dic)     msg = MIMEMultipart()
    msg['From'] = '你的发件地址,可以写主机名'
    msg['Subject'] = Header('我爱北京天安门', 'utf-8')
    msg['Date'] = formatdate(localtime=True)
    #to = ['wangquanjun@xxx.com', 'wangquanjun@xxx.com']
    msg['To'] = ','.join(to)
    msg.attach(MIMEText(mail, _subtype='plain', _charset='utf-8'))     server = smtplib.SMTP('邮件服务器主机名')
    err = server.sendmail('****@yq01-ps-exdata-svr00.yq01', to, msg.as_string())
    logger.info(err)
    server.quit()

python 发邮件 utf-8的更多相关文章

  1. python发邮件遇到的端口号问题

    在学习使用python发邮件的过程中, 遇到了一个问题:由于测试的时候使用的是QQ邮箱,要求必须使用SSL/TLS加密,所以有了下面的代码, from email.mime.text import M ...

  2. 使用python发邮件

    使用python发邮件 网上有很多发邮件的例子,本人在网上找了一份,稍加修改后使用 上源码 # encoding=utf-8 from email.mime.image import MIMEImag ...

  3. 如何用python发邮件

    python发送各类邮件的主要方法 一.相关模块介绍 发送邮件主要用到了smtplib和email两个模块,这里首先就两个模块进行一下简单的介绍:     1.smtplib模块 smtplib.SM ...

  4. Python 发邮件例子

    Python 发邮件例子 例子 #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2019-04-23 16:12:33 # @Autho ...

  5. [转]简单三步,用 Python 发邮件

    https://zhuanlan.zhihu.com/p/24180606 0. 前言 发送电子邮件是个很常见的开发需求.比如你写了个监控天气的脚本,发现第二天要下雨,或者网站上关注的某个商品降价了, ...

  6. Python—发邮件总结

    来自: http://my.oschina.net/jhao104/blog/613774 1.登录SMTP服务器 首先使用网上的方法(这里使用163邮箱,smtp.163.com是smtp服务器地址 ...

  7. 人生苦短之Python发邮件

    #coding=utf-8 import smtplib from email.mime.base import MIMEBase from email.mime.image import MIMEI ...

  8. python 发邮件-带附件-文本-html

    #!/usr/bin/python # encoding=utf-8 # Filename: send_email.py from email.mime.image import MIMEImage ...

  9. 用python发邮件实例

    发QQ邮件 首先确认发件方是否打开了SMTP服务,去QQ邮箱的设置中查看,如果没有请自行开启. from email.header import Header from email.mime.text ...

随机推荐

  1. Struts2_使用 Filter 作为控制器的 MVC 应用

  2. C# Ajax 手机发送短信验证码 校验验证码 菜鸟级别实现方法

    1.Ajax请求处理页面: using System; using System.Collections.Generic; using System.Linq; using System.Web; u ...

  3. sql语句添加约束

    sql语句添加约束 --主键约束(Primary Key constraint):要求主键列的数据唯一,并且不允许为空. --唯一约束(Unique Constraint):要求该列唯一,允许为空,但 ...

  4. WCF之数据契约

    从抽象层面看,WCF能够托管CLR类型(接口和类)并将它们公开为服务,也能够以本地CLR接口和类的方式使用服务.然而,CLR类型却属于.NET的特定技术.由于面向服务的一个核心原则就是在跨越服务边界时 ...

  5. linux 信号列表和基本作用

    我们运行如下命令,可看到Linux支持的信号列表: $ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7 ...

  6. redis setnx 分布式锁

    private final String RedisLockKey = "RedLock"; private final long altTimeout = 1 * 60 * 60 ...

  7. CentOS6.4下使用默认的PDF文档阅读器出现乱码的解决方案

    方法一:修改/etc/fonts/conf.d/49-sansserif.conf文件,如下: 1: <?xml version="1.0"?> 2: <!DOC ...

  8. 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法

    $x_pi = 3.14159265358979324 * 3000.0 / 180.0; //火星坐标系 (GCJ-02)转百度坐标系 (BD-09)算法 function bd_encrypt($ ...

  9. 理解 pkg-config 工具

    引用了别人的文章:http://www.chenjunlu.com/2011/03/understanding-pkg-config-tool/ 你在 Unix 或 Linux 下开发过软件吗?写完一 ...

  10. TextView中gravity属性值测定

    Attributes Explain top 不改变控件大小,对齐到容器顶部 bottom 不改变控件大小,对齐到容器底部 left 不改变控件大小,对齐到容器左侧 right 不改变控件大小,对齐到 ...