libgmail — Python binding for Google's Gmail service

Project Page | Downloads | Contact

The libgmail project is a pure Python binding to provide access to Google's Gmail web-mail service.

Please note: Always download and test the CVS version of libgmail if you are having problems.

Example code

The following code logs into an account, retrieves a list of threads, displays information about them and displays the source of the individual messages.

import libgmail

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

Archive Gmail messages to mbox format

The library currently ships with one demonstration utility to archive messages from an Gmail account into mbox files, suitable for importing into a local email client.

Use your Gmail account as a SMTP server

The library now includes a demonstration utility gmailsmtp.py that sets up a SMTP proxy on port 8025 of your computer to enable you to use a standard mail client (e.g. Mozilla, Mail.app) to send messages. (Attachments are now supported.)

Use your Gmail account as a POP server

The library now includes a demonstration utility gmailpopd.py that sets up a POP3 proxy on port 8110 of your computer to enable you to use a standard mail client (e.g. Mozilla, Mail.app) to retrieve messages.

Use your Gmail account as a FTP server!

The included demonstration gmailftpd.py sets up a download-only FTP proxy on port 8021 of your computer to enable you to use a standard ftp client to retrieve message attachments that have the label 'ftp'.

License: GPL 2.0

Other resources


SourceForge.net Logo