/***************************************************************************
* python auto send email
* 声明:
* 本文主要是记录如何使用python的smtplib发邮件,中间遇到授权密码和邮箱
* 密码不同的问题。
*
* 2016-2-17 深圳 南山平山村 曾剑锋
**************************************************************************/ 一、参考文章:
163邮箱报错WARN: Error: authentication failed.啥问题?
http://www.zhihu.com/question/32009096 二、error:
. 错误现象:
(, 'Error: authentication failed')
. 解决办法:
smtplib用的邮箱登入密码是授权密码,不是邮箱密码。授权密码需要在邮箱设置中设置,我用的是163的邮箱,所以需要在163邮箱中设置。 三、demo code:
# encoding: utf-
import smtplib sender = "zengjf42@163.com"
receivers = ["64128306@qq.com"] message = """From: zengjf <zengjf42@163.com>
To: zoro <@qq.com>
Subject: test email for python this is a test email.
""" try:
smtpObj = smtplib.SMTP()
smtpObj.connect("smtp.163.com", "")
# 千万请注意下面的password是授权密码,不是邮箱的密码。
# 授权密码需要在163邮箱设置中设置。
state = smtpObj.login("zengjf42@163.com", "填入授权密码")
if state[] == :
smtpObj.sendmail(sender, receivers, message)
print "send email success"
smtpObj.quit()
except smtplib.SMTPException, e:
print str(e)

python auto send email的更多相关文章

  1. Send Email in Robot Framework Python Using Gmail

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

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

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

  3. Robot Framework通过Python SMTP进行email收发测试。

    工作中需要对发送的邮件进行过滤,方法基本属于ACL控制,即查看“源/目的”邮件地址,邮件标题,邮件正文,邮件附件等进行过滤. 所以需要先模拟一下用Python能否达到邮件Client,Server的功 ...

  4. python trojan development 1st —— use python to send mail and caputre the screen then combine them

    import smtplib from email.mime.text import MIMEText msg_from='1@qq.com' #发送方邮箱 passwd='bd' #填入发送方邮箱的 ...

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

  6. Python中send()和sendall()的区别

    Python中send()和sendall()的区别 估计每个学习Python网络编程的人,都会遇到过这样的问题: send()和sendall()到底有什么区别? send()和sendall()原 ...

  7. 5 Ways to Send Email From Linux Command Line

    https://tecadmin.net/ways-to-send-email-from-linux-command-line/ We all know the importance of email ...

  8. [476] Database Mail is not enabled for agent notifications. Cannot send e-mail to

    配置完DB Mail后JOB的的通知邮件不能发送,日志报错476] Database Mail is not enabled for agent notifications. Cannot send ...

  9. python send email

    #!/usr/bin/python # -*- coding: UTF-8 -*- # coding:utf8 from smtplib import SMTP_SSL from email.head ...

随机推荐

  1. Spark Streaming揭秘 Day33 checkpoint的使用

    Spark Streaming揭秘 Day33 checkpoint的使用 今天谈下sparkstreaming中,另外一个至关重要的内容Checkpoint. 首先,我们会看下checkpoint的 ...

  2. 拓展,Fibonacci螺旋

    #该程序由023递归这课中的fibonacci数列递归写法修改而成 #在写的过程中发现,如果要正确引导用户的每一次输入,写的代码比主程序还要多 #当然,为了使程序在用户交互过程中显得更加友好,提供错误 ...

  3. (转载)Cocos2dx-OpenGL ES2.0教程:你的第一个立方体(5)

    在上篇文章中,我们介绍了VBO索引的使用,使用VBO索引可以有效地减少顶点个数,优化内存,提高程序效率. 本教程将带领大家一起走进3D–绘制一个立方体.其实画立方体本质上和画三角形没什么区别,所有的模 ...

  4. The ‘Microsoft.ACE.OLEDB.12.0′ provider is not registered on the local machine. (System.Data)

    When you try to import Excel 2007 or later “.xlsx” files into an SQL Server 2008 database you may ge ...

  5. [SQL SERVER系列]存储过程,游标和触发器实例[原创]

    自己写的存储过程与游标结合使用的实例,与大家分享,也供自己查阅,仅供参考: --使用游标循环处理,删除重复的记录 declare @UserID int ) ) declare @UnitFlag i ...

  6. iphone编程,使用代码结束程序

    (ios 4环境) 1.使用代码可以结束自己只有一种方式,而且apple不建议这样用,就是调用exit()函数.在2.0以前uiapplication类中有一个方法可以调用,但是现在已经没有了,而且如 ...

  7. CSS3新的字体尺寸单位rem

    CSS3引入新的字体尺寸单位 rem ,可以简单记忆为root rm. CSS3的出现,他同时引进了一些新的单位,包括我们今天所说的rem.在W3C官网上 是这样描述rem的——“font size ...

  8. spoj 364

    动规  f[i][j]表示第i到第j个数能取到的最大值 e[i][j]表示最小值 ....... #include <cstdio> #include <cstring> us ...

  9. About javascript closure

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Closures?redirectlocale=en-US&redi ...

  10. PHP获取APP客户端的IP地址的方法

    分析php获取客户端ip 用php能获取客户端ip,这个大家都知道,代码如下: /** * 获取客户端ip * @param number $type * @return string */ func ...