mailinabox/tests/imap.py

16 lines
379 B
Python
Raw Normal View History

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