Skip to content

Instantly share code, notes, and snippets.

@semihozkoroglu
Created January 9, 2013 21:11
Show Gist options
  • Save semihozkoroglu/4496983 to your computer and use it in GitHub Desktop.
Save semihozkoroglu/4496983 to your computer and use it in GitHub Desktop.
for google mail backup
import getpass, imaplib
M = imaplib.IMAP4_SSL('imap.googlemail.com', '993')
M.login('semihozkoroglu', getpass.getpass())
M.select()
typ, data = M.search(None, 'ALL')
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print 'Message %s\n%s\n' % (num, data[0][1])
M.close()
M.logout()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment