0

下一个脚本在我的 Mac 上运行良好。当我尝试在我的 WebHosting(bluehost)上运行它时,我得到了socket.error: [Errno 101] Network is unreachable. 知道如何解决吗?

#!/usr/bin/python
# Required header that tells the browser how to render the text.
print "Content-type: text/html\r\n\r\n";

import imaplib
mail = imaplib.IMAP4_SSL('imap.gmail.com')
mail.login('user@gmail.com', 'password')
mail.list()
# Out: list of "folders" aka labels in gmail.
mail.select("inbox") # connect to inbox.
print mail.list()


Traceback (most recent call last):
  File "test2.py", line 6, in <module>
    mail = imaplib.IMAP4_SSL('imap.gmail.com')
  File "/home4/user/python27/lib/python2.7/imaplib.py", line 1148, in __init__
    IMAP4.__init__(self, host, port)
  File "/home4/user/python27/lib/python2.7/imaplib.py", line 163, in __init__
    self.open(host, port)
  File "/home4/user/python27/lib/python2.7/imaplib.py", line 1159, in open
    self.sock = socket.create_connection((host, port))
  File "/home4/user/python27/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 101] Network is unreachable

他们的支持根本没有帮助。

它可以与端口相关还是 SSL?

4

1 回答 1

1

在 bluehosts帮助页面上,他们提到传出连接受到限制,因此问题不在于您的程序。允许出站连接的唯一方法似乎是为此付出代价。

于 2013-05-06T21:37:51.193 回答