Here is an example of processing your GMail IMAP email in Python.
The script below will:
- login to GMail account using IMAP
- open your Inbox
- retrieve and print all messages
- close mailbox
- logout
# Script adapted from Corey Goldberg
# http://coreygoldberg.blogspot.com/2011/07/python-processing-gmail-imap-email.html
#!/usr/bin/env python import imaplib USER = 'username@gmail.com' PASSWORD = 'xxx' mail = imaplib.IMAP4_SSL('imap.gmail.com', 993) mail.login(USER, PASSWORD) mail.select('Inbox') status, data = mail.search(None, 'ALL') for num in data[0].split(): status, data = mail.fetch(num, '(RFC822)') print 'Message %s\n%s\n' % (num, data[0][1]) mail.close() mail.logout()