IMAP è molto simile a POP3 con l’unica differenza che lavora su più dispositivi contemporanemente, la sintassi per comunicare con questo protocollo è la seguente:
LOGIN <username> <password> autentica l'utente
SELECT <mailbox> seleziona la cartella della casella di posta con cui lavorare
FETCH <mail_number> <data_item_name> Esempio fetch 3 body[] per recuperare il messaggio numero 3, intestazione e corpo.
MOVE <sequence_set> <mailbox> sposta i messaggi specificati in un'altra casella di posta
COPY <sequence_set> <data_item_name> copia i messaggi specificati in un'altra casella di posta
LOGOUT esegue la disconnessioneEsempio
user@TryHackMe$ telnet 10.10.41.192 143
Trying 10.10.41.192...
Connected to 10.10.41.192.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN] Dovecot (Ubuntu) ready.
A LOGIN strategos
A OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE SORT SORT=DISPLAY THREAD=REFERENCES THREAD=REFS THREAD=ORDEREDSUBJECT MULTIAPPEND URL-PARTIAL CATENATE UNSELECT CHILDREN NAMESPACE UIDPLUS LIST-EXTENDED I18NLEVEL=1 CONDSTORE QRESYNC ESEARCH ESORT SEARCHRES WITHIN CONTEXT=SEARCH LIST-STATUS BINARY MOVE SNIPPET=FUZZY PREVIEW=FUZZY PREVIEW STATUS=SIZE SAVEDATE LITERAL+ NOTIFY SPECIAL-USE] Logged in
B SELECT inbox
* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)
* OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.
* 4 EXISTS
* 0 RECENT
* OK [UNSEEN 2] First unseen.
* OK [UIDVALIDITY 1719824692] UIDs valid
* OK [UIDNEXT 5] Predicted next UID
B OK [READ-WRITE] Select completed (0.001 + 0.000 secs).
C FETCH 3 body[]
* 3 FETCH (BODY[] {445}
Return-path: <[email protected]m>
Envelope-to: [email protected]
Delivery-date: Thu, 27 Jun 2024 16:19:35 +0000
Received: from [10.11.81.126] (helo=client.thm)
by example.thm with smtp (Exim 4.95)
(envelope-from <[email protected]m>)
id 1sMrpq-0001Ah-UT
for [email protected];
Thu, 27 Jun 2024 16:19:35 +0000
From: [email protected]
To: [email protected]
Subject: Telnet email
Hello. I am using telnet to send you an email!
)
C OK Fetch completed (0.001 + 0.000 secs).
D LOGOUT
* BYE Logging out
D OK Logout completed (0.001 + 0.000 secs).
Connection closed by foreign host.