google
Skip to main content.
Septiembre 22nd, 2007  español 

libgmail throught HTTP(S) proxy

Computer Science Programming

libgmail is, in words of its author, a pure python binding to provide access to your gmail account.

I’m using it and find it very useful. However, within my organization, I must connect to the internet via an HTTP/HTTPS proxy firewall. Direct internet connections are filtered, so I developed a hack to make it to work via an HTTP(S) proxied connection.

Basically I ripped the code from this ASPN snippet, and derived the urllib proxied transport to create a new one.

To use it behind a proxy, you can copy the libgmail example, and define the proxy this way:

import libgmail

libgmail.PROXY_URL = 'www.myproxy.org:3128'  # Define the proxy.

ga = libgmail.GmailAccount("google@gmail.com", "mymailismypass")
ga.login()
folder = ga.getMessagesByFolder('inbox')

for thread in folder:
    print thread.id, len(thread), thread.subject
    for msg in thread:
        print "  ", msg.id, msg.number, msg.subject
    print msg.source

I patched the libgmail.py file and write the proxied transport in another one: gmail_transport.py. You will need to copy both the file gmail_transport.py and the modified version of libgmail.py (overwrite it) into the same directory libgmail.py is installed.

There is also a diff file available, for libgmail-0.6.1.2.

Update (2007-10-06): It’s now possible to use proxy authentication. To do it so, you must use the proxy host address on the previous example this way: user:password@myproxy.org:3128 where user and password are your proxy user and password respectively. You’ll have to download again the file gmail_transport.py.

Now, the example to use it behind a proxy requiring with user/passwd authentication is like this:

import libgmail

# Connect from behind a proxy www.myproxy.org:3128 using
# proxy authentication user = 'john', password = 'proxy4321'
libgmail.PROXY_URL = 'john:proxy4321@www.myproxy.org:3128'  # Define the proxy 

ga = libgmail.GmailAccount("google@gmail.com", "mymailismypass")
ga.login()
folder = ga.getMessagesByFolder('inbox')

for thread in folder:
    print thread.id, len(thread), thread.subject
    for msg in thread:
        print "  ", msg.id, msg.number, msg.subject
    print msg.source

Posted by Boriel as Computer Science, Programming at 7.57 pm

Rate This Post: 1 Stars2 Stars3 Stars4 Stars5 Stars
2 Votes | Average: 5 out of 52 Votes | Average: 5 out of 52 Votes | Average: 5 out of 52 Votes | Average: 5 out of 52 Votes | Average: 5 out of 5 (2 votes, average: 5 out of 5)
9 Comments »
Septiembre 9th, 2007  español 

Yessssssss!

Computer Science

Finally it’s over.
I officially finished the final project for my carreer. The project topic was related to parallelism, and it was entited “Dynamic Data Structures on Shared Memory. An implementation with OpenMP”. So I finally have a degree of Bachelor of Science on Computer Sciences, and avoid the horrible university studies plan about to enter in the next two years here, in Spain (which, in my opinion, degrade the level of knowledge).

A friend of mine, Khertz, came to the lecture and took this pic.

Lecture announce / Anuncio de la defensa

Posted by Boriel as Sin categoría, Computer Science at 11.38 am

Rate This Post: 1 Stars2 Stars3 Stars4 Stars5 Stars
2 Votes | Average: 4 out of 52 Votes | Average: 4 out of 52 Votes | Average: 4 out of 52 Votes | Average: 4 out of 52 Votes | Average: 4 out of 5 (2 votes, average: 4 out of 5)
4 Comments »
Septiembre 6th, 2007

“P” time countdown…

Posted by Boriel as Sin categoría at 7.41 am

Rate This Post: 1 Stars2 Stars3 Stars4 Stars5 Stars
No Ratings Yet
2 Comments »
  


You are viewing a mobilized version of this site...
View original page here

Mobilized by Mowser Mowser