Skip to content
A simple library to interact with Gmail through python
Pull request Compare 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.

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

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)


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.


A large part of this library is implementing this excellent blogpost:

Something went wrong with that request. Please try again.