#!/usr/bin/env python

#coding: utf-8  

import smtplib  

from email.mime.text import MIMEText  

from email.header import Header  

sender = 'tom'  

receiver = ['john@sina.com', 'lili@163.com']  

subject = 'python email test'  

smtpserver = 'smtp.sina.com'  

username = 'yourusername'  

password = 'yourpassword'  

msg = MIMEText('你好','text','utf-8')#中文需参数‘utf-8’,单字节字符不需要  

msg['Subject'] = Header(subject, 'utf-8')  

smtp = smtplib.SMTP()  

smtp.connect(smtpserver)  

smtp.login(username, password)  

smtp.sendmail(sender, receiver, msg.as_string())  

smtp.quit()

  

python smtplib发email的更多相关文章

  1. Python smtplib发邮件

    常用邮箱SMTP.POP3域名及其端口号 发送普通文本内容的邮件 import smtplib from email.header import Header from email.mime.text ...

  2. Python自动发邮件——smtplib和email库和yagmail库

    ''' 一.先导入smtplib模块 导入MIMEText库用来做纯文本的邮件模板 二.发邮件几个相关的参数,每个邮箱的发件服务器不一样,以163为例子百度搜索服务器是 smtp.163.com 三. ...

  3. Python自动发邮件-yagmail库

    之前写过用标准库使用Python Smtplib和email发送邮件,感觉很繁琐,久了不用之后便忘记了.前几天看知乎哪些Python库让你相见恨晚?,看到了yagmail第三方库,学习过程中遇到一些问 ...

  4. 【Python】 发邮件用 smtplib & email

    smtplib & email ■ 概述 发邮件主要用到smtplib以及email模块.stmplib用于邮箱和服务器间的连接,发送的步骤.email模块主要用于处理编码,邮件内容等等.主要 ...

  5. python smtplib email

    监控系统需要触发报警邮件, 简单笔记一下的用到的库. smtplib class smtplib.SMTP([host[, port[, local_hostname[, timeout]]]]) 返 ...

  6. python之smtplib发邮件

    第一版: 认证发信,不支持附件 #!/usr/bin/env python # --------------------------------------- # author : Geng Jie ...

  7. Python自动发送邮件-smtplib和email库

    ''' 一.先导入smtplib模块 导入MIMEText库用来做纯文本的邮件模板 二.发邮件几个相关的参数,每个邮箱的发件服务器不一样,以163为例子百度搜索服务器是 smtp.163.com 三. ...

  8. 【python】使用python smtplib库发邮件添加cc,bcc

    #!/usr/bin/env python# -*- coding: utf-8 -*- '''@author@mail @date 2017/03/16 发送邮件'''import smtplibf ...

  9. python 利用 smtplib发邮件

    import smtplib from email.mime.text import MIMEText title = "request build error" content ...

随机推荐

  1. [Swift]LeetCode476. 数字的补数 | Number Complement

    Given a positive integer, output its complement number. The complement strategy is to flip the bits ...

  2. [Swift]LeetCode488. 祖玛游戏 | Zuma Game

    Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), gre ...

  3. [Swift]LeetCode566. 重塑矩阵 | Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  4. [Swift]LeetCode972.相等的有理数 | Equal Rational Numbers

    Given two strings S and T, each of which represents a non-negative rational number, return True if a ...

  5. MySQL 规范及优化

    一.建库建表优化 1.核心规范(推荐) 表字符集选择UTF8 (“表情”字段单独设置为其他字符集) 存储引擎使用INNODB 不在库中存储图片.文件等 使用可变长字符串(varchar) 每张表数据量 ...

  6. Linux 遭入侵,挖矿进程被隐藏排查记录

    今天来给大家分享下这两天遇到的一个问题,服务器被挖矿了,把我的排查记录分享下,希望能帮到有需要的同学. 问题原因 多台服务器持续告警CPU过高,服务器为K8s的应用节点,正常情况下CPU使用率都挺低的 ...

  7. 关于pycharm安装出现的interpreter field is empty,无法创建项目存储位置

    关于pycharm安装出现的interpreter field is empty(解释器为空) 关于pycharm安装出现的interpreter field is empty,无法创建项目存储的位置 ...

  8. JS对json操作的扩展

    一.JSON对象 JSON是 JavaScript 的原生对象,用来处理 JSON 格式数据.它有两个静态方法:JSON.stringify()和JSON.parse(). JSON.stringif ...

  9. CSRF攻击原理及防御

    一.CSRF攻击原理 CSRF是什么呢?CSRF全名是Cross-site request forgery,是一种对网站的恶意利用,CSRF比XSS更具危险性.想要深入理解CSRF的攻击特性我们有必要 ...

  10. 那些令人惊艳的TensorFlow扩展包和社区贡献模型

    随着TensorFlow发布的,还有一个models库(仓库地址:https://github.com/tensorflow/models),里面包含官方及社群所发布的一些基于TensorFlow实现 ...