#-*-coding: utf-8 -*-

'''
使用Python去发送邮件
但是不成功,运行后,等待一段时间, 返回[Errno 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
email send fail
'''

import smtplib
from email.mime.text import MIMEText

HOST='smtp.163.com'
PORT=25
TIMEOUT='30'
USER='m17606719860'
USERA='m17606719860@163.com'
PREFIX='163.com'
PASSWORD='cc1842'
to_list=['chen.chen@ecitele.com']
content='python send email test'
sub='hello,world'

def sendmail(to_list,sub,content):
me='hello'+'<'+USER+'@'+PREFIX+'>'
msg=MIMEText(content,_subtype='plain',_charset='gb2312')
msg['Subject']= sub
msg['From']=me
msg['To']=','.join(to_list)
try:
smtp=smtplib.SMTP()
smtp.set_debuglevel(1)
smtp.connect(HOST,PORT)
smtp.login(USER,PASSWORD)
smtp.sendmail(me,to_list,msg.as_string())
smtp.quit()
print 'email send success'
except Exception,e:
print e
print 'email send fail'

if __name__=='__main__':sendmail(to_list,sub,content)

Try to write a script to send e-mail but failed的更多相关文章

  1. Cannot send, channel has already failed:

    背景: 一个同事往这个队列发数据,另一个同事从这个队列取数据,进行解析. 这是昨天同事昨天消费者 消费activemq 队列,一开始有正常,运行了一段时间后,发现突然消费者变为零了.因为有监控.之后怎 ...

  2. org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed

    项目是使用activeMQ 发布订阅的模式,在本地测试正常,但是 放到服务器上出现这个错误: org.apache.activemq.transport.InactivityIOException: ...

  3. Send [1] times, still failed

    com.alibaba.rocketmq.client.exception.MQClientException: Send [1] times, still failed, cost [696094] ...

  4. fwrite(): send of 8192 bytes failed with errno=104 Connection reset by peer

    问题:fwrite(): send of 8192 bytes failed with errno=104 Connection reset by peer 问题描述 通过mysql + sphinx ...

  5. UiPath: Send SMTP Mail Message 发送带附件的邮件

    Tips:关于Hotmail的server和port的获取方式,请参考以下链接 https://support.office.com/en-us/article/Server-settings-you ...

  6. PHP系列 | PDO::prepare(): send of 68 bytes failed with errno=32 Broken pipe

    设计场景 1.开启Redis的键空间过期事件(键过期发布任务),创建订单创建一个过期的key,按照订单号为key,设置过期时间. 2.通过Redis的订阅模式(持久阻塞),获取到订单号进行组装. 3. ...

  7. ActiveMQ Cannot send, channel has already failed: tcp:127.0.0.1:8161

    仅针对如下错误内容: Cannot send, channel has already failed: tcp://127.0.0.1:8161 一种尝试解决,修改连接端口为 61616: tcp:/ ...

  8. CentOs安装Scrapy出现error: Setup script exited with error: command ‘gcc’ failed with exit status 1错误解决方案

    按照 http://www.1207.me/archives/209.html 的教程安装Scrapy出现了上述错误,但是本身机器已经有了gcc,所以应该是安装包的问题 百度又看到了同博客里的解决方案 ...

  9. Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 解决办法

    今天在Ubuntu16.04 上安装python包的时候,出现了这个坑爹的问题: 解决办法,内容总结如下 情况是这样,报错是因为没有把依赖包安装全,报错情况如下图: 解决办法,先安装一些必须的依赖: ...

随机推荐

  1. cookie和session简单的用法

    一.登录成功则设置cookie和session 二.在登录页判断是否已记住密码 三.在首页判断,和创建会话区 四.在首页执行并显示

  2. C# (灰度)加权平均法将图片转换为灰度图

    private Bitmap ToG(string file) { using (Bitmap o = new Bitmap(file)) { Bitmap g = new Bitmap(o.Widt ...

  3. jQuery实现按enter键登录

    <script> $(document).keydown(function (event) { if (event.keyCode == 13) { $("#btn_Login& ...

  4. 用于 Linux 平台的 Java

    切换到所需的安装目录.键入:cd directory_path_name例如,要将软件安装到 /usr/java/ 目录中,请键入:cd /usr/java/ 将 .tar.gz 档案二进制文件移到当 ...

  5. SSH整合报错:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped[......]

    非常诡异的报错,信息如下:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [select count(* ...

  6. DEV全选多选小技巧

    var v1 = bindingSourceBase.DataSource as DataTable; foreach (DataRowView v in v1.DefaultView) { v[&q ...

  7. Java多线程学习(三)

    一.线程的异常(续) 在上一篇博文中我们提到了Thread.UncaughtExceptionHandler接口,我们在日常的编写中可以通过实现这一接口来给每一个Thread对象都附着一个异常处理器, ...

  8. VB.NET中Form窗体运行时,按ESC退出全屏状态

    1.在其KeyDown事件添加: If e.KeyValue = 27 Then Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable ...

  9. python 中使用celery

    http://www.thinksaas.cn/group/topic/395734/

  10. sqlserver查询数据的所有表名和行数

    //查询所有表明 select name from sysobjects where xtype='u' select * from sys.tables //查询数据库中所有的表名及行数 SELEC ...