mailinabox/tests/imap.py

14 lines
327 B
Python
Raw Normal View History

2013-08-21 13:37:33 +00:00
import imaplib, os
M = imaplib.IMAP4_SSL(os.environ["INSTANCE_IP"])
M.login("testuser@testdomain.com", "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()