2.3 Email
Overview of Email Application
Email is one of the internet's oldest and most fundamental applications, dating back to . It revolutionized communication long before the World Wide Web became mainstream.
It operates primarily on an asynchronous communication model; unlike instant messaging, the sender and receiver do not need to be online simultaneously.
The architecture relies on the client-server model, utilizing a network of distributed mail servers to facilitate message relay.
Key Components of Email Infrastructure
User Agent (UA): Also known as a mail client (e.g., Microsoft Outlook, Apple Mail, Thunderbird). It allows users to read, reply to, forward, save, and compose messages.
Email Servers: The core of the infrastructure. Each user has a mailbox located on a mail server which manages and stores messages.
Message Queue: If the recipient's server is temporarily unreachable, the sending server holds the message in a queue and attempts re-transmission (typically every minutes).
SMTP Protocol (Simple Mail Transfer Protocol): The primary application-layer protocol for email. It governs how mail is moved from the sender\'s UA to the sender\'s mail server, and between mail servers.
Detailed Email Sending Process (Alice to Bob)
Alice uses her User Agent to compose a message and enters Bob's address ().
Alice's UA sends the message to her mail server using SMTP; the message is placed in the server's outgoing message queue.
Alice's mail server (acting as an SMTP client) initiates a TCP connection on port to Bob's mail server (the SMTP server).
After a multi-step SMTP handshake, the message is uploaded to Bob's server over the established TCP connection.
Bob's mail server receives the message and places it in Bob's specific mailbox.
Bob invokes his user agent to read the message at his convenience via an access protocol (like IMAP or POP3).
SMTP Protocol Specifics
Reliability: Uses TCP (port ) to ensure reliable delivery of messages without data loss.
Three Phases of Transfer:
Handshake: The client greets the server with
HELO(orEHLO) and the server responds with status code (ready).Transfer of messages: Commands like
MAIL FROM,RCPT TO, andDATAare used to define the sender, recipient, and the content.Closure: The command
QUITterminates the connection.
Persistence: SMTP uses persistent connections; if a sender has multiple messages for the same destination server, it can send them all over the same TCP connection.
Data Requirements: SMTP traditionally requires the message (header and body) to be in -bit ASCII. Binary data (like images or PDFs) must be encoded using MIME (Multipurpose Internet Mail Extensions).
Comparison: SMTP vs. HTTP
Push vs. Pull:
SMTP is a push protocol: the sending host initiates the connection to "push" the file to the receiver.
HTTP is a pull protocol: the user initiates the connection to "pull" information from the server.
Encoding: SMTP requires all content to be -bit ASCII-encoded, whereas HTTP does not have this restriction and can transport any binary data directly.
Document Structure: HTTP encapsulates each object in its own response message, while SMTP can send multiple objects (parts of a message) as a single integrated set within one message body.
Email Message Format and MIME
RFC 822/2822 Header: Contains peripheral information required by the User Agent, separated from the body by a blank line. Key fields include:
To:Recipient address.From:Sender address.Subject:Brief summary of the email.
MIME Extensions: Added to the header to allow non-ASCII content. It includes fields like
Content-Type(e.g.,image/jpegormultipart/mixed) andContent-Transfer-Encoding.
Mail Access Protocols: Retrieving the Email
Since Bob cannot use SMTP to "pull" mail from his server (as SMTP is a push-only protocol), specific access protocols are required:
POP3 (Post Office Protocol - Version 3): A "download and delete" protocol. Once Bob downloads his mail to his device, it is typically deleted from the server, making it difficult to access from multiple devices.
IMAP (Internet Mail Access Protocol): A more advanced protocol that allows users to organize messages into folders on the server. IMAP maintains state across different sessions, allowing Bob to see the same folder structure and "read/unread" status from any device.
HTTP (Web-based Email): Services like Gmail or Outlook.com use HTTP as the interface between the browser (User Agent) and the mail server. SMTP is still used between servers in the background.