mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-22 07:17:05 +00:00
21 lines
429 B
Python
Executable File
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()
|
|
|