As its name implies, IMAP allows you to access your email messages wherever you are; much of the time, it is accessed via the Internet. Basically, email messages are stored on servers. Whenever you check your inbox, your email client contacts the server to connect you with your messages. When you read an email message using IMAP, you aren't actually downloading or storing it on your computer; instead, you are reading it off of the server. As a result, it's possible to check your email from several different devices without missing a thing.
By default, the IMAP protocol works on two ports:
Port 143 - this is the default IMAP non-encrypted port
Port 993 - this is the port you need to use if you want to connect using IMAP securely
PORT STATE SERVICE REASON143/tcp open imap syn-ack
nc -nv <IP> 143openssl s_client -connect <IP>:993 -quiet
LoginA1 LOGIN username passwordValues can be quoted to enclose spaces and special characters. A " must then be escape with a \A1 LOGIN "username" "password"List Folders/MailboxesA1 LIST "" *A1 LIST INBOX *A1 LIST "Archive" *Create new Folder/MailboxA1 CREATE INBOX.Archive.2012A1 CREATE "To Read"Delete Folder/MailboxA1 DELETE INBOX.Archive.2012A1 DELETE "To Read"Rename Folder/MailboxA1 RENAME "INBOX.One" "INBOX.Two"List Subscribed MailboxesA1 LSUB "" *Status of Mailbox (There are more flags than the ones listed)A1 STATUS INBOX (MESSAGES UNSEEN RECENT)Select a mailboxA1 SELECT INBOXList messagesA1 FETCH 1:* (FLAGS)A1 UID FETCH 1:* (FLAGS)Retrieve Message ContentA1 FETCH 2 body[text]A1 FETCH 2 allA1 UID FETCH 102 (UID RFC822.SIZE BODY.PEEK)Close MailboxA1 CLOSELogoutA1 LOGOUT