2017-04-19 23 views
1

我测试下面的代码用不同的电子邮件服务器,只有smtp.gmail.com是响应以下简单的代码:为什么有些电子邮件服务器不响应smtlib.SMTP('xxxx')?

>>> import smtplib 
>>> s=smtplib.SMTP('smtp.gmail.com') 
>>> s.help() 
'2.0.0 https://www.google.com/search?btnI&q=RFC+5321 b188sm4817528wmh.6 - gsmtp' 
>>> s.quit() 
(221, '2.0.0 closing connection b188sm4817528wmh.6 - gsmtp') 

很确定。

但是这(和许多其他提供商)超时:

>>> s=smtplib.SMTP('smtpmail.t-online.de') 

返回错误:

error: [Errno 10061] No connection could be made because the target machine actively refused it

>>> s=smtplib.SMTP('wpxxxxxxxx.mailout.server-he.de',25) 

返回:

error: [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

我认为是因为SSL。所以我用:

>>> smtplib.SMTP_SSL("wpxxxxxxx.mailout.server-he.de", 465) 

尝试与不同的端口nr的。电子邮件服务器的名称一定正确 那么什么是独特的关于smtp.gmail.com? 我怎么能让其他人工作?

-Thanks-

+0

尝试使用端口587。 – Barmar

回答

0

在尝试此我自己,我碰到可能不同的问题,可以帮助别人。这是我的发现。

互联网服务提供商是可怕的。各方面。

在这种情况下,我的ISP阻止端口25

从我的本地机器我尝试这样做。

>>> import smtplib 
>>> s=smtplib.SMTP('smtp.gmail.com') 

这最终超时了相同的error: [Errno 10060]

好奇,我回落到远程登录

$ telnet smtp.gmail.com 25 
Trying ... 
telnet: Unable to connect to remote host: Connection timed out 

咦?为什么GMail会放弃我的连接请求?除非......

$ ssh some.ec2.machine 
$ python 
>>> import smtplib 
>>> s=smtplib.SMTP('smtp.gmail.com') 
>>> 

,瞬间连接..原来,我的ISP,还有谁,但康卡斯特,阻止所有流量通过端口25

通过使用VPS,我是能够建立连接到Google邮件和其他主机。

我试图为您指定的地址相同的Telnet连接:

$ telnet smtpmail.t-online.de 25 
telnet: connect to address 194.25.134.114: Connection refused 
telnet: connect to address 194.25.134.115: Connection refused 

Connection Refused的情况下,这是在服务器端配置错误。

通常,服务器将接受数据包或完全丢弃数据包。在这种情况下,服务器正在运行,并主动拒绝连接。

相关问题