【问题标题】:Error while sending email from hotmail smtp Python从 hotmail smtp Python 发送电子邮件时出错
【发布时间】:2012-07-28 17:51:44
【问题描述】:

我正在尝试使用以下代码发送电子邮件:

s = smtplib.SMTP("smtp.live.com",587, timeout=120)
    s.ehlo()
    s.starttls() 
    s.ehlo()
    s.login(user, pass)
msg["To"] = string.joinfields(bundle, ", ")
    s.sendmail(usuario, bundle, msg)

但是我得到以下错误:

  File "C:\Python27\lib\smtplib.py", line 242, in __init__
    (code, msg) = self.connect(host, port)
  File "C:\Python27\lib\smtplib.py", line 302, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "C:\Python27\lib\smtplib.py", line 277, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "C:\Python27\lib\socket.py", line 571, in create_connection
    raise err
error: [Errno 10060] A connection attempt failed because the connected party did
 not properly respond after a period of time, or established connection failed b
ecause connected host has failed to respond

我做错了什么?

【问题讨论】:

    标签: python smtplib


    【解决方案1】:

    没什么,我想。您可能在防火墙后面,或者 hotmail 的日子不好过。在命令提示符下,尝试telnet smtp.live.com 587。如果您没有收到回复,则说明您的连接有问题。

    这是我得到的结果:

    $ telnet smtp.live.com 587
    Trying 65.55.96.11...
    Connected to smtp.hot.glbdns.microsoft.com.
    Escape character is '^]'.
    220 BLU0-SMTP406.phx.gbl Microsoft ESMTP MAIL Service, Version: 6.0.3790.4675 ready at  Mon, 30 Jul 2012 19:37:46 -0700 
    

    【讨论】:

    • 真的,是连接问题。它可以在另一台机器上运行。
    • 这是一个简单的解决方案,然后:)
    猜你喜欢
    • 2021-12-31
    • 2015-02-21
    • 2017-02-25
    • 1970-01-01
    • 2014-01-04
    • 1970-01-01
    • 1970-01-01
    • 2013-03-12
    相关资源
    最近更新 更多