A mail delivery agent (MDA) is the software component that takes a message already accepted by a mail server and writes it into the recipient’s mailbox on local storage. In email infrastructure on the Internet, the MDA is the last hop of the server-side chain: the mail transfer agent moves messages between hosts, and the MDA performs final local delivery, often applying filtering, sorting and quota rules before the message becomes visible to the user.
The MDA rarely appears in user-facing discussions, yet it decides where a message is stored, in which format and under which rules. Problems in this stage explain many cases in which a message was accepted by the server but never reached the expected folder.
How a mail delivery agent completes the delivery chain
A mail delivery agent receives a message from the mail transfer agent (MTA) after the MTA has decided that the recipient is local. The MTA hands over the message through a local pipe, LMTP or a direct program call, together with the envelope recipient. The MDA then resolves the target mailbox, runs any user or system filters, and stores the message.
The handoff interface determines how errors propagate. With a pipe, the MDA reports success or failure through exit codes, and the MTA interprets a temporary code as a reason to retry. With the Local Mail Transfer Protocol (LMTP), defined in RFC 2033, the MDA returns a separate status for each recipient, which avoids duplicate deliveries when one of several recipients fails.
The table below shows the stages that a typical delivery passes through after SMTP acceptance.
| Stage | Component | Result |
|---|---|---|
| Recipient lookup | MTA | Message marked as local |
| Handoff | MTA to MDA via pipe or LMTP | Envelope and body transferred |
| Mailbox resolution | MDA | User and storage path identified |
| Filtering | MDA with Sieve or procmail rules | Target folder chosen or message discarded |
| Storage | MDA | Message written to Maildir or mbox |
| Indexing and notification | MDA or IMAP server | Client sees the new message |
Common MDA implementations and mailbox formats
Several programs serve as mail delivery agents, and they differ mainly in filtering language, protocol support and integration with the mailbox server. Modern deployments favor an MDA that is part of the IMAP server, because shared indexes and quota accounting stay consistent.
| MDA | Interface | Filtering | Typical deployment |
|---|---|---|---|
| Dovecot LDA and LMTP | Pipe or LMTP | Sieve | Postfix or Exim with Dovecot IMAP |
| procmail | Pipe | procmail recipes | Legacy Unix servers |
| maildrop | Pipe | maildrop language | Courier-based systems |
| Cyrus deliver and LMTP | LMTP | Sieve | Cyrus IMAP clusters |
| Exim local transports | Internal | Exim filters | Single-host Exim servers |
The storage format is equally important. Maildir stores one file per message, which makes concurrent access safe without locking. mbox stores all messages in one file, which is compact but requires locking and suffers when files grow large. Proprietary formats such as Dovecot’s mdbox trade portability for higher performance on large mailboxes.
How the MDA differs from the MTA and MSA
The MDA is defined by its role, not by a separate product category: the same software package can contain an MTA, an MDA and an IMAP server. The functional split between agents comes from the Internet mail architecture described in RFC 5598, which separates submission, relay and delivery.
| Agent | Main task | Typical protocol | Example software |
|---|---|---|---|
| Mail submission agent | Accepts mail from authenticated users | SMTP on port 587 | Postfix submission service |
| Mail transfer agent | Routes and relays mail between hosts | SMTP on port 25 | Postfix, Exim |
| Mail delivery agent | Stores mail in the local mailbox | LMTP or local pipe | Dovecot LMTP, procmail |
| Mailbox access server | Serves stored mail to clients | IMAP or POP3 | Dovecot, Cyrus |
A common misconception is that the email client delivers mail. The client only retrieves messages through IMAP or POP3; the message was already placed in storage by the MDA before the client connected.
Configuring filtering, quotas and error handling
Most operational decisions about an MDA concern filtering rules, quota policy and temporary failure handling. The Sieve language, standardized in RFC 5228, is the preferred filtering mechanism because users can edit rules safely through ManageSieve without shell access.
- Spam folder routing: a Sieve rule reads the spam score header added earlier by the spam filter and files the message into a Junk folder.
- Quota enforcement: the MDA rejects or defers a message when the mailbox exceeds its limit, and the chosen behavior decides whether the sender receives a bounce message.
- Vacation responses: the Sieve vacation extension sends automatic replies with rate limits per sender to avoid mail loops.
- Duplicate suppression: LMTP status per recipient and message-ID tracking prevent repeated copies after retries.
Error handling should follow one rule: temporary problems must produce temporary failures. If the storage volume is briefly unavailable, the MDA should return a 4xx-class or temporary exit status so the MTA keeps the message in its queue instead of bouncing it.
Failure modes and common configuration mistakes
Delivery-stage failures are hard to diagnose because the sender already received a successful SMTP reply. The following table links typical symptoms to their causes and fixes.
| Symptom | Likely cause | Fix |
|---|---|---|
| Message accepted but missing | Sieve rule discarded or misfiled it | Review active filters and delivery logs |
| Duplicate messages | Pipe delivery retried after partial success | Switch to LMTP with per-recipient status |
| Bounces for full mailbox | Quota set to permanent rejection | Use temporary deferral with warning messages |
| Corrupted mbox file | Concurrent writes without locking | Migrate to Maildir or a locking-aware MDA |
| Wrong file ownership | MDA running as an incorrect system user | Correct the user mapping and permissions |
A security point deserves attention: an MDA that executes user-defined programs, as procmail recipes can, runs code with the privileges of the mailbox owner. Restricting external program execution and keeping the MDA unprivileged limits the damage from malicious messages or misconfigured rules.
The short version
Think of email as a postal system. Mail servers on the Internet act like sorting centers that pass letters from city to city. The mail delivery agent is the local carrier who takes a letter at the last post office and puts it into the right mailbox in your building.
It can also sort your post on the way, for example by putting advertising into a separate tray. When something goes wrong at this last step, a letter can arrive at the building but never reach your box, which is why administrators check the delivery agent first when a message seems to vanish.
Where it makes a difference
A university IT team runs Postfix as its mail transfer agent and Dovecot for about 20,000 student mailboxes. Students complain that some messages from course systems never appear, although the sending systems record successful SMTP delivery. The delivery logs show that Postfix hands messages to Dovecot through a pipe, and that a default Sieve script files all messages with a high spam score into a Junk folder that many students never open.
The team switches the handoff to Dovecot LMTP, adjusts the Sieve rule so that messages from the internal course platform bypass spam routing, and changes quota handling from rejection to temporary deferral with warning emails. Within a semester, support tickets about missing course messages fall to a small fraction of their former volume, and full mailboxes no longer generate bounces to teaching staff.