Python module for GMail
Simple Python module to interact with Google's mail service GMail. The module uses Python's included imaplib and smtplib for recieving and sending emails.
The goal of this module is to provide a simple direct interface to GMail.
To initialize an account you do the following
import gmaillib account = gmaillib.account('username', 'password')
To get messages from the inbox just call the use the inbox method
To get a range of messages just give the place to start from and how many to fetch
This will fetch the 10th to the 110th message
To get the entire contents of the inbox(note if you have a large inbox this could take a while)
You can also just get the number of messages in the inbox which is less time consuming.
To only get the unread messages of the inbox
To send an email
account.send(target, subject, message)
Note that the subject and message are optional.
To fetch emails with gmail search syntax. Added support for gmails web search syntax using X-GM-RAW.
Note that, the mailbox selection is set to Inbox(default). https://github.com/shredder12/gmaillib/blob/master/gmaillib.py#L65
Download messages by using download_attachment()
A large part of this library is implementing this excellent blogpost: http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/