Email Protocol used for managing mails on a mail Server.
Emails are kept on the server and synchronised to one or many clients. This is contrary to POP3 which downloads them to a single Client and deletes the mail from the server afterwards.
It supports creating, renaming, and deleting folders on the server.
By default IMAP use port 143 and when using SSL/TLS port 993.
Commands
Communication is done with text-based commands in ASCII format:
LOGIN <username> <password>: user’s login.LIST "" *: lists all directories.CREATE "<mailbox>": creates a mailbox with a specified name.DELETE "<mailbox>": deletes a mailbox.RENAME "<from name>" "<to name>": renames a mailbox.LSUB "" *: returns a subset of subscribed folders.SELECT <mailbox>: selects a mailbox so that messages in the mailbox can be accessed.UNSELECT <mailbox>: exits the selected mailbox.FETCH <ID> all: retrieves data associated with a message in the mailbox.CLOSE: removes all messages with the deleted flag set.LOGOUT: closes the connection.
You might have to add a alphanumeric prefix in front the commands. This is because IMAP can be done asynchronous with multiple commands.
Examples
Retrieve content of Email
openssl s_client -connect 10.129.179.28:993
a1 login robin robin
a2 list "" *
a3 SELECT "DEV.DEPARTMENT.INT"
a4 FETCH 1 RFC822These commands login with robin:robin, see available folders, select a folder and retrieves content of first mail in the folder.