Wednesday, October 28, 2009

DIY: Google Mail Notifier

It's quite easy to create your own GMail notifier. Your inbox, gmail or domain,  can be monitored by fetching and parsing an atom feed.

Following code snippet prints new (unread) mail in your inbox:
# -*- coding: utf-8 -*-
import feedparser
import urllib2

# Create http basic auth handler
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('New mail feed', '',
                          'USERNAME@DOMAIN', 'PASSWORD')

# Open url using the auth handler
opener = urllib2.build_opener(auth_handler)
feed_file ='')

# Parse feed using feedparser
d = feedparser.parse(feed_file)

# Print mail count and mails
print 'Mail count:', d.feed.fullcount

for entry in d.entries:
        print '----------------------------------------------'
 print 'Author: ',
 print 'Subject:', entry.title
 print 'Summary:', entry.summary

Just change USERNAME and PASSWORD. You also need to download feedparser which is free to use, or write one yourself.

Have fun!


  1. thank u for this tutorial, but how secure is it? =)

  2. It should be secure (if you mean sending your password over the network) since the traffic is encrypted using ssl (https) to the web-server.

    I've inspected the network traffic with wireshark and it appears to be ok (encrypted).