How Email Is Delivered
SMTP Delivery on the Internet Explained
The journey of an email from the outbox of the sender to the inbox of the receiver involves multiple assets and protocols. The message is relayed through multiple processing elements until it is in the hands of the receiver.
Definitions
- SMTP - Simple Mail Transfer Protocol: The protocol to transfer email. It carries the addressing information for routing a message through to the right destination.
- MUA - Mail User Agent: The email client with the user interface to compose an email, read received emails and browse the inbox. Microsoft Outlook App, Mac Mail and Thunderbird are examples of MUA user clients. Many email services offer web-clients which allow users to write emails and manage their inbox in their internet browser.
- MTA - Mail Transport Agent: The central element in delivering email. It examines the destination addressing and decides its destination server.
- MDA - Mail Delivery Agent: The server which manages the inbox and the database of all its messages.
- IMAP - Internet Message Access Protocol: The protocol for a MUA to manage the inbox. This includes reading received mail and managing them.
SMTP Mail Delivery MUA to MTA
The first step in the email delivery is the transfer between the MUA user client and the MTA. It is executed when the user hits the send button.
This first MTA is provided by the email service. The email submission over SMTP requires authentication by the user. To protect the authentication and email submission is protected by TLS (Transport Layer Security).
SMTP Relaying & Delivery Between MTAs
MTAs are for email, what routers are for IP packets: They transmit the email based on their SMTP addressing. But instead of routing, this is called relaying. In order to find the IP address of the destination MTA, the sending MTA uses DNS.
During its journey, an email message traverses through multiple MTAs until it reaches the inbox of the receiver. This transmission is done on the internet backbone and is usually unencrypted and unprotected.
Local Delivery to Inbox
After the email is accepted by its final MTA, this MTA commits the message to the inbox database. The email is now ready to be read by the receiving user.
In the simplest case, the inbox database is a folder and file tree with a standard structure (maildir). But some email services - like Microsoft Exchange - often implement their proprietary solutions. In all cases, the local delivery takes place on a private network.
Accessing the Inbox with IMAP
After delivery, emails are kept in the inbox database of the MDA. The MUA email client of the receiver uses the IMAP protocol to access and manage the inbox.
This includes fetching email data for reading, but also managing the folders, moving emails between directories and deleting messages.
IMAP manages the inbox, but it does not transmit messages for sending. For transmission, the MUA uses SMTP for that. That is the reason why users commonly have to configure both an SMTP and an IMAP connection when setting up their email client for a new inbox.
MTA Mail Processing
Every MTA processes incoming mail delivery requests according to the SMTP protocol. For the processing of every mail, the MTA has to decide what to do with the message. There are three possible outcomes:
- The message is selected for local processing. This means either delivery into a local inbox or passing it on to a local service.
- The message is relayed (forwarded) to another MTA over SMTP.
- The message is discarded.
- The message is rejected - returned to the sender.
The MTA decision process is complex and highly configurable. The decision process can be based on:
- The envelope delivery address
- The network identity of the sending server
- The email headers and security controls
- Whether or not the sender is authenticated
Typical MTA architectures are more complex. It is common to have a single MTA at the network boundary accepting all mail for a domain. But rather than delivering the mail to a local inbox, the message is relayed to secondary MTAs. For example: A big organization may distribute incoming mail to MTAs dedicated to departments inside the organization.