Email Tutorials - Herong's Tutorial Examples - v1.04, by Herong Yang
What Is IMAP
This section provides a quick introduction on IMAP (Internet Message Access Protocol) for retrieving email messages. An IMAP sample session of retrieving an email message using the 'telnet' command is included.
What Is IMAP? - IMAP (Internet Message Access Protocol) is a communication protocol used by MUA (Message User Agent) to retrieve email messages stored by a MDA (Message Delivery Agent). See the diagram "Email Processing and Software Agents / Protocols" listed in the last section.
The original version of IMAP was published in 1988 by M. Crispin in "RFC1064 - Internet Message Access Protocol - Version 2" ( datatracker.ietf.org/doc/html/rfc1064).
The latest version of IMAP was published in 2021 by A. Melnikov and B. Leiba in "RFC1064 - Internet Message Access Protocol (IMAP) - Version 4rev2" ( datatracker.ietf.org/doc/html/rfc9051).
Here is a sample session of retrieving an email message with IMAP using "telnet" as the MUA. A Dovecot server is used to access email messages stored by a MDA.
herong$ telnet 127.0.0.1 143 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. * OK [CAPABILITY IMAP4rev1 SASL-IR LOGIN-REFERRALS ID ENABLE IDLE LITERAL+ STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready. c1 login herong TopSecret c1 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 LITERAL+ NOTIFY SPECIAL-USE] Logged in c2 select "INBOX" * FLAGS (\Answered \Flagged \Deleted \Seen \Draft) * OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted. * 2 EXISTS * 0 RECENT * OK [UIDVALIDITY 1605272831] UIDs valid * OK [UIDNEXT 22] Predicted next UID c2 OK [READ-WRITE] Select completed (0.001 + 0.000 secs). c3 fetch 1 RFC822 * 1 FETCH (RFC822 {416} Return-Path: <herong@herongyang.com> X-Original-To: herong Delivered-To: herong@herongyang.com Received: from localhost (localhost [IPv6:::1]) by mail.herongyang.com (Postfix) with ESMTP id 5EABD266002B for <herong>; 15 Nov 2023 06:19:34 -0500 (EST) Message-Id: <20231113111946.5EABD266002B@mail.herongyang.com> Date: 15 Nov 2023 06:19:34 -0500 (EST) From: herong@herongyang.com Hello world! ) c3 OK Fetch completed (0.022 + 0.000 + 0.021 secs).
Note that retrieving email messages with IMAP is not secure, because data is transmitted in clear text. So most of email systems are not using IMAP directly anymore. They are using the IMAPS (Internet Message Access Protocol Secure) method to secure the IMAP communication. This is done by wrapping the IMAP communication under a SSL (Secure Socket Layer) or TLS (Transport Layer Security) connection. See next section for more details on IMAPS.
Table of Contents
Postfix - Mail Transport Agent (MTA)
SSL/TLS Secure Connections with Postfix Server
Dovecot - IMAP and POP3 Server
SSL/TLS Secure Connections with Dovecot Server
Email Client Tools - Mail User Agents (MUA)
Mozilla Thunderbird - Mail User Agents (MUA)
PHPMailer - PHP Package for Sending Emails