5 minute read


This is a compendium of some old notes, partly mine, partly from external sources.
In the references section there are some links to the sources that could have been identified.


Electronic Mail (aka E-mail) is an internet service that allow users to send and to receive messages and files (e-mails) in a fast, low-cost, and efficient way.

We call mail servers the systems that provide this service either in private networks or publicly on Internet.

Basic flow

Basic mail flow:

  1. An email is written in a MUA and submitted to a mail server’s MSA: port 587, which is for submitting mail to a the server, frequently (but not required to be) encrypted using STARTTLS.
  2. The MSA and check for any errors before submitting the mail to the MTA port 25 (normally in the same SMTP server as the MSA).
  3. The MTA checks the MX record off the recipient domain and transfers the message to another MTA. Mail is routed from server to server port 25 (MTAs) one or more times until arrives to the recipient’s MTA.
  4. The MTA hands the email off to the incoming mail server MDA, which stores the email for retrieval by the receiving MUA
  5. The receiving MUA requests the message from the MDA (usually with POP3 port 110 or IMAP port 143).
  6. The message is delivered to the receiving MUA’s inbox.


Service Elements

The mail servers have often to perform different tasks depending on their role, e.g.: read, answer, transfer messages, deliver messages, etc.

These are the agents in the mail flow process:

Mail User Agent (MUA)

MUA or Mail User Agent is basically the Mail client that we install in our desktops. It allows us to read, write, answer, and dispose (for example: delete or archive) the e-mails. It also use the standard rules of composing an e-mail, including fields as From and others, and manage attachments MIME (Multipurpose Internet Mail Extensions).

Examples of MUA are:

  • mail (for BSD and others)
  • mutt
  • Thunderbird Mail
  • Outlook

Mail Submission Agent (MSA)

MSA or Mail Submission Agent stands between the MUA and the MTA in a mail system. It acts as a sort of receptionist (port 587) for messages coming in to a mail system from MUAs.

It does error checking and verification (such as verifying that hostnames are FQDNs, checking the legitimacy of local hostnames before appending the local domain portion, fixing headers, etc.) before passing the message off to the MTA for transmission.

The MSA and the MTA are usually hosted on the same SMTP server, as the MSA acts as a “front-end” of the MTA.

They also are relatively new. Prior to their existence, all this work was handled by the MTA. See RFC 2476.

Examples of MSA are:

Mail Transfer Agent (MTA)

The MTA or Mail Transfer Agent (also called mail relay) is the software that checks recipient domain’s MX record to decide how to continue transferring the message (either to another MTA, or an MDA) and transfers emails from one computer to another using SMTP (port 25). It is used for communication between MTAs, or from an MSA to an MTA, this distinction is first made in RFC 2476.

When a recipient mailbox of a message is not hosted locally, the message is relayed, that is, forwarded to another MTA. Every time an MTA receives an email message, it adds a Received trace header field to the top of the header of the message,[4] thereby building a sequential record of MTAs handling the message. The process of choosing a target MTA for the next hop is also described in SMTP, but can usually be overridden by configuring the MTA software with specific routes.

Examples of MTA are:

  • postfix
  • sendmail
  • qmail
  • exim

Mail Delivery Agent (MDA)

The MDA or Mail Delivery Agent is the incoming mail server, which stores the email as it waits for the user to accept it.

The client will connect to the MDA with their MUA to retrieve the email stored.

There are two main protocols used for retrieving email on an MDA:

  • POP3 - Post Office Protocol
  • IMAP - Internet Message Access Protocol

POP3 is the older of the two, and is used for retrieving email and, in certain cases, leaving a copy of it on the server.

IMAP, on the other hand, is used for coordinating the status of emails (read, deleted, moved) across multiple email clients. With IMAP, a copy of every message is saved on the server, so that this synchronization task can be completed.

For this reason, incoming mail servers are called POP servers or IMAP servers, depending on which protocol is used.

To use a real-world analogy, MTAs act as the post office (the sorting area and mail carrier), which handle message transportation, while MDAs act as mailboxes, which store messages (as much as their volume will allow) until the recipients check the box. This means that it is not necessary for recipients to be connected in order for them to be sent email.

To keep everyone from checking other users’ emails, MDA is protected by a user name called a login and by a password.

Retrieving mail is done using a software program called an MUA (Mail User Agent). When the MUA is a program installed on the user’s system, it is called an email client (such as Mozilla Thunderbird, Microsoft Outlook, Eudora Mail, Incredimail or Lotus Notes).

Examples of MDA are:

  • dovecot
  • fetchmail
  • procmail
  • bin/mail, the MDA part of sendmail
  • postfix LDA (local delivery agent)


Jump to Mail II: Types, protocols and ports

Jump to Mail III: Local mail storage