1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2024-11-30 03:37:05 +00:00
mailinabox/tests/imap.py

21 lines
429 B
Python
Raw Normal View History

2013-08-31 14:46:25 +00:00
#!/usr/bin/python3
import imaplib, sys
2013-08-21 13:37:33 +00:00
2013-08-31 14:46:25 +00:00
if len(sys.argv) < 3:
print("Usage: tests/imap.py host username password")
sys.exit(1)
2013-08-23 15:59:28 +00:00
2013-08-31 14:46:25 +00:00
host, username, pw = sys.argv[1:4]
M = imaplib.IMAP4_SSL(host)
M.login(username, pw)
2013-08-21 13:37:33 +00:00
print("Login successful.")
2013-08-31 14:46:25 +00:00
M.select()
2013-08-21 13:37:33 +00:00
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()