power-mailinabox/tests/imap.py
Joshua Tauberer 97b2105a1f spamassassin
2013-08-23 11:59:28 -04:00

15 lines
379 B
Python

import imaplib, os
username = "testuser@" + os.environ.get("DOMAIN", "testdomain.com")
M = imaplib.IMAP4_SSL(os.environ["INSTANCE_IP"])
M.login(username, "testpw")
M.select()
print("Login successful.")
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()