Hacking Gmail

(Grace) #1

132 Part II — Getting Inside Gmail


FIGURE7-3: Python’s Libgmail binding

You should follow the instructions on their website to install the latest version. As
mentioned before, if Libgmail stops working, it may just be a matter of time
before a new version restores functionality.

How to Use It


Libgmail comes with some sample code, but no real documentation at the
moment. There are currently 15 methods available, which offer the vast majority
of the functionality that Gmail can give. Start by logging in.

login
To log in, import the Libgmail bindings, create a new GmailAccountobject, and
use the loginmethod on it, like so:

import Libgmail

ga = Libgmail.GmailAccount(“[email protected]”,
“mymailismypass”)
ga.login()

Now that you’re logged in, you want to retrieve the messages from a folder.
Free download pdf