Skip to content

Instantly share code, notes, and snippets.

@jperras
Created April 29, 2011 21:21
Show Gist options
  • Select an option

  • Save jperras/949063 to your computer and use it in GitHub Desktop.

Select an option

Save jperras/949063 to your computer and use it in GitHub Desktop.
Did imaplib just tell me to go fuck myself?
import getpass, imaplib
# The following snippet will fetch all emails from an IMAP server.
M = imaplib.IMAP4()
M.login(getpass.getuser(), 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