When a receiving SMTP server replies 4xx instead of 5xx, what does the sending MTA do, and when is a bounce sent?
answer
- temporary versus permanent
- the queue keeps the envelope too
- wait before retrying the same destination
- give up after days, not hours
- MAIL FROM:<> on the notification
basics
~20 sA 4xx is temporary: the sending MTA queues and retries, RFC 5321 suggesting 30 minutes or more between tries and 4-5 days before giving up. A 5xx, or giving up, triggers a bounce sent from the null sender <>.
solid answer
~50 sThe reply's first digit tells the MTA holding the message what to do. A `4yz` is a transient failure, so the holder keeps the message, with its envelope, in its queue and tries again. RFC 5321 section 4.5.4.1 says it MUST wait before retrying a failed destination, that the interval SHOULD in general be at least 30 minutes, and that the give-up time generally needs to be at least 4-5 days; Postfix's `maximal_queue_lifetime` defaults to `5d`. A `5yz` is permanent: the holder stops and sends a non-delivery notification to the envelope reverse-path, the `MAIL FROM` address, not the `From` header. That notification is a delivery status notification (DSN, RFC 3464) whose `Action:` field reads `failed` or `delayed`. It goes out with the null reverse-path `MAIL FROM:<>`, and RFC 5321 forbids notifying a null address, so a bounce is not bounced again.
go deeper
Recall that 4xx means try again later and 5xx means give up, and that the bounce goes back to the envelope sender from the null sender <>.
Explain RFC 5321's sending strategy: queue with the envelope, delay before retrying, at least 30 minutes in general, give up after at least 4-5 days, and how a DSN reports failed or delayed per recipient.
Show you can read a DSN's Action, Status and Diagnostic-Code to locate a failure, and explain why rejecting in the session puts the bounce on the sender's own MTA.
Decide queue lifetimes and delay notices per mail stream: a password-reset message is worthless after hours, while an invoice should keep trying for days, and the defaults suit neither.
## Who holds the message, and what the first digit tells it At every hop one MTA holds the message and another is asked to take it. The holder might be your outbound server sending to a remote MX, or a submission server forwarding to the next hop. The receiver's reply decides what the holder does next; the full grammar of replies is covered with the command and reply sequence, and only the consequence for the queue matters here. | Reply class | Meaning for the holder | What it does | |---|---|---| | `2yz` after the data | responsibility has passed | removes the recipient from its queue | | `4yz` (e.g. `421`, `450`, `451`) | transient, try later | keeps the message queued and retries | | `5yz` (e.g. `550`, `554`) | permanent, do not repeat | stops and returns a notification to the sender | Once a receiver has answered `250` to the end of data, RFC 5321 section 6.1 says it has **accepted responsibility**: it MUST NOT lose the message for frivolous reasons, and if delivery later fails it MUST send a notification itself. ## The retry queue RFC 5321 section 4.5.4.1, "Sending Strategy", sets the rules a sending MTA follows: - Mail that cannot be sent immediately **MUST** be queued and periodically retried, together with its envelope (`MAIL FROM` and the `RCPT TO` list). - The sender **MUST** delay before retrying a destination after a failed attempt. - The retry interval **SHOULD in general be at least 30 minutes**, although "more sophisticated and variable strategies" are welcome when the client knows why delivery failed. - The give-up time **generally needs to be at least 4-5 days**; it MAY be shorter for notifications than for ordinary mail, and the parameters **MUST be configurable**. - Experience, the RFC adds, favours two attempts in the first hour and then one every two or three hours. - A `5yz` reply to `MAIL` **MUST NOT be cached**: refusing one sender in one transaction says nothing certain about the next. The reference MTA shows how those figures become settings. Postfix's `maximal_queue_lifetime` and `bounce_queue_lifetime` both default to `5d`. Its retry spacing runs between `minimal_backoff_time` (default `300s`) and `maximal_backoff_time` (default `4000s`), so out of the box Postfix's first retries come sooner than the RFC's 30-minute figure, which is a SHOULD stated "in general", not a MUST. Postfix's `delay_warning_time` defaults to `0h`, meaning no "still trying" notice unless you set one. ## The bounce: a delivery status notification When the holder gives up, after a `5yz` or at the end of the queue lifetime, it sends a **non-delivery notification**. The standard form is a **DSN**: 1. **RFC 3461** adds SMTP parameters a sender can use to steer DSNs: `NOTIFY` on `RCPT` (`NEVER`, or any of `SUCCESS`, `FAILURE`, `DELAY`), `RET` on `MAIL` (`FULL` or `HDRS`, how much of the original to return), `ENVID` and `ORCPT` to label the report. With no `NOTIFY`, a server may act as if `FAILURE` or `FAILURE,DELAY` was asked. 2. **RFC 3464** defines the machine-readable part, `message/delivery-status`, carried inside a `multipart/report` (now RFC 6522, which obsoleted RFC 3462). 3. Per recipient, the report names the outcome: | Field | What it tells you | |---|---| | `Reporting-MTA` | the MTA that wrote the report | | `Final-Recipient` | the address the failure concerns | | `Action` | `failed`, `delayed`, `delivered`, `relayed` or `expanded` | | `Status` | the enhanced status code, e.g. `5.1.1` bad destination mailbox, or the `X.4.7` delivery-time-expired codes of RFC 3463 | | `Diagnostic-Code` | the remote server's reply text, when there was one | | `Will-Retry-Until` | for a delay, when the holder will give up | ## The null sender, and why it exists RFC 5321 section 4.5.5 says notifications about a previous message are sent **with a null reverse-path**, `MAIL FROM:<>`, to that message's reverse-path. Section 6.1 then adds the rule that stops loops: if the reverse-path is null, the server **MUST NOT** send a notification. So a bounce that cannot itself be delivered is not bounced again; some hosts route such failures to the postmaster alias instead. Automated processors SHOULD NOT reply to a null reverse-path, and SHOULD NOT turn one into a non-null address when forwarding. The bounce goes to the **envelope** sender, the `MAIL FROM` address that final delivery records as `Return-Path`, not to the `From` header the reader sees. How the two identities differ is covered with envelope against header. ## Rejected in the session or bounced later The same failure produces a bounce from different places: - **Refused during the session** with a `5yz`: the *sending* MTA still holds the message and writes the bounce to its own user, whose address it knows is real. - **Accepted, then undeliverable**: the receiver now holds it and must notify the reverse-path. If that address was forged, an innocent party receives the bounce, which is backscatter. ## Common mistakes - Treating a `4yz` as lost mail. It is queued and retried for days. - Expecting the bounce at the `From` address. - Reading "at least 30 minutes" as a fixed timer; the RFC sets a general floor, not a schedule.
- Why does RFC 5321 say a 5yz reply to MAIL must not be cached?A refusal of `MAIL` belongs to that transaction: a sender address, a policy or a listing that may change. If the client cached it per host, it would fail other queued messages to the same server that the receiver would accept, so RFC 5321 says such replies MUST NOT be cached.
- How does a sender learn that a message is delayed rather than failed?Only if someone sends a delay DSN, with `Action: delayed` and often `Will-Retry-Until`. RFC 3461's `NOTIFY=DELAY` requests one. In Postfix the notice depends on `delay_warning_time`, whose default `0h` sends none; setting it sends the sender the queued message's headers after that delay.
A 4xx is the courier's card saying nobody was in and they will call again; a 5xx is 'no such address, return to sender'. The returned parcel carries no return address of its own, so if it cannot be delivered either, it is not sent back again; it goes to the depot's supervisor.
- A 4xx reply means the message was lost and the user must resend it.
- Bounces are sent to the address in the From header.
- RFC 5321 fixes the retry interval at exactly 30 minutes.
- A bounce should use the postmaster address as its MAIL FROM so replies reach someone.
- After a 5xx the sending MTA should keep retrying for five days anyway.