Skip to content

Instantly share code, notes, and snippets.

@kmila
Created October 26, 2015 18:17
Show Gist options
  • Save kmila/f91fa08c84fa25128985 to your computer and use it in GitHub Desktop.
Save kmila/f91fa08c84fa25128985 to your computer and use it in GitHub Desktop.
import imaplib
M = imaplib.IMAP4_SSL('imap.oi.com.br')
if (M.login('<USER_TO_TEST>@oi.com.br','PASSWORD')[0] != 'OK'): exit("no conn")
c = (M.select('Inbox'))[1][0]
if (c != '0'):print c
typ, data = M.search(None, '(SEEN)')
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print('Message %s\n%s\n' % (num, data[0][1]))
M.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment