1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-22 02:17:26 +00:00
mailinabox/tests/imap.py
2013-08-31 10:50:27 -04:00

21 lines
429 B
Python
Executable File

#!/usr/bin/python3
import imaplib, sys
if len(sys.argv) < 3:
print("Usage: tests/imap.py host username password")
sys.exit(1)
host, username, pw = sys.argv[1:4]
M = imaplib.IMAP4_SSL(host)
M.login(username, pw)
print("Login successful.")
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()