I am trying to add a python script to a shared web hosting account and I cannot get even the most basic of scripts to establish a valid imap connection to gmail. Just as a test case, I created the following script:
import imaplib
conn = imaplib.IMAP4_SSL("imap.gmail.com", 993)
conn.login(<EMAIL_ADDRESS>, <PASSWORD>)
This produces the following ouput:
Traceback (most recent call last):
File "imapTest.py", line 2, in ? conn = imaplib.IMAP4_SSL("imap.gmail.com", 993) File "/usr/lib64/python2.4/imaplib.py", line 1101, in init IMAP4.init(self, host, port) File "/usr/lib64/python2.4/imaplib.py", line 160, in init self.open(host, port) File "/usr/lib64/python2.4/imaplib.py", line 1113, in open self.sock.connect((host, port)) File "", line 1, in connect socket.error: (110, 'Connection timed out')
How would I go about troubleshooting this issue? Is it possible that my hosting provider is blocking outgoing imap requests?
-
TELNET is always a good general purpose TCP testing tool that's available out-of-the-box on most OS's.
Can you TELNET to imap.gmail.com, port 993, from the shell on your hosted box and get an open TCP connection? If not, I'd start talking to the host about whether or not they're blocking that traffic.
Edit:
To test connectivity to an arbitrary TCP port with TELNET you need to specify the port number on the TELNET command like. For port 993, for example:
telnet imap.gmail.com 993
If you don't specify a port number the default port for TELNET, port 23, is assumed.
sglantz : I tried to test the connection with telnet, but it isn't working. The output is as follows. Trying 74.125.157.109... telnet: connect to address 74.125.157.109: Connection timed out telnet: Unable to connect to remote host: Connection timed out That appears to be correct IP address, but the connection obviously isn't established.sglantz : Sorry about the formatting in the above post. After more testing it appears that no telnet connection is working. I tried connecting to serverfault.com and I received the same output expect the IP address was 69.59.196.212.Evan Anderson : I'm dropping on an edit re: thee comments.sglantz : Oops, sorry about that mistake. Still no connection with imap.gmail.com on port 993, but I can establish other connections on port 80.Evan Anderson : Sounds like your outbound connections are being filtered by something, then.sglantz : Thanks, you have given me enough evidence to show my host that the problem isn't with either Gmail or my Python script (their original excuses). They just admitted that port 993 was blocked and they will open it up.From Evan Anderson
0 comments:
Post a Comment