Created
November 28, 2016 23:58
-
-
Save studiawan/a6d7ebe8673b8b992e30d1a87d7a9c9a to your computer and use it in GitHub Desktop.
Read email via IMAP command line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
BUFF = 1024 | |
mail_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
mail_socket.connect(('mail.***.edu', 143)) | |
mail_socket.recv(BUFF).strip() | |
commands = ['a1 LOGIN ***@***.edu ***\r\n', 'a2 LIST "" "*"\r\n', 'a3 EXAMINE INBOX\r\n', 'a4 LOGOUT\r\n'] | |
for command in commands: | |
mail_socket.send(command) | |
print 'S:', mail_socket.recv(BUFF).strip() | |
mail_socket.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment