Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A simple library to interact with Gmail through python
Python
branch: master

This branch is 4 commits ahead, 42 commits behind thedjpetersen:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.md
gmaillib.py
test.py

README.md

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.

Usage

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

account.inbox()

To get a range of messages just give the place to start from and how many to fetch

account.inbox(start=10, amount=100)

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)

account.get_all_messages()

You can also just get the number of messages in the inbox which is less time consuming.

account.get_inbox_count()

To only get the unread messages of the inbox

account.unread();

To send an email

account.send(target, subject, message)

Note that the subject and message are optional.

Credits

A large part of this library is implementing this excellent blogpost: http://yuji.wordpress.com/2011/06/22/python-imaplib-imap-example-with-gmail/

Something went wrong with that request. Please try again.