IMAP4_SSL, libgmail, GMail and corporate firewall/proxy

Andrea Gavana andrea.gavana at
Thu Feb 17 23:40:19 EST 2011

Hi Malcolm,

On 17 February 2011 19:20,  <python at> wrote:
> Hi Andrea,
> Have you tried temporarily turning off your Windows firewall software
> and/or any locally installed internet security software like Norton,
> Avast, etc? You don't need to turn off your entire security package,
> just the component that controls internet access.

I'd love to, but it's not under my control. The IT department has an
iron grip on these things and there is no way I can do what you
proposed :-(

> If the problem can not be resolved locally, then I believe you need to
> contact your IT department to have them create the firewall rules that
> will allow you to access gmail services. I'm basing that suggestion on
> googling the various error messages (10060, 10061) you received and
> reading the answers. That's my interpretation, anyway.

I though that I could do what Chrome/Firefox do: as far as I can
understand, they seem to use the company proxy settings to access the
web (and this is also what the "about:config" in Firefox is telling
me: it gives all the proxy servers and ports I need). However, even
the simplest piece of code using urllib2 and trying to read the Python
web page like this:

import urllib2

user_agent = 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:
              Ubuntu/10.04 (lucid) Firefox/3.6.10'

request = urllib2.Request('')
request.add_header('User-agent', user_agent )

proxy_info = {
    'user' : username,
    'pass' : password,
    'host' : proxy_server,
    'port' : 993 # or 8080 or whatever

proxy = "http://%(user)s:%(pass)s@%(host)s:%(port)d" % proxy_info
proxy_support = urllib2.ProxyHandler({"http" : proxy})

opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)


Fails with a variety of errors depending on which port I use:

- Port 80: urllib2.HTTPError: HTTP Error 407: Proxy Authentication
Required ( The ISA Server requires authorization to fulfill the
request. Access to the Web Proxy filter is denied.  )

- Port 143: urllib2.URLError: <urlopen 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>

- Port 8080: urllib2.HTTPError: HTTP Error 403: Forbidden ( The server
denied the specified Uniform Resource Locator (URL). Contact the
server administrator.  )

Etc... etc...

I am going to try all the ports from 1 to 10000 and see what happens,
just for the fun of it. I am sure I will get 10000 errors, with mixed
frequency. :-( :-(

If someone can see what I am doing wrong, please do let me know... I'm
running our of ideas...

> I'm a big fan of your wxPython and GUI builder contributions!!

Thank you, I'm happy you found them useful!


"Imagination Is The Only Weapon In The War Against Reality."

==> Never *EVER* use RemovalGroup for your house removal. You'll
regret it forever. <==

More information about the Python-list mailing list