skip to content

In an SMTP EHLO response, what do the PIPELINING, SIZE and CHUNKING keywords advertise, and how does each change the dialog?

level: middleimportance: should knowfreq 18%

answer

  1. EHLO reply as a capability list
  2. batch commands, last-in-group rule
  3. declare size before sending
  4. counted chunks instead of the dot

basics

~20 s

PIPELINING (RFC 2920) lets a client batch commands without waiting for each reply; SIZE (RFC 1870) advertises the largest accepted message and lets MAIL FROM declare one; CHUNKING (RFC 3030) adds BDAT, sending counted chunks instead of DATA.

solid answer

~40 s

Each keyword in the `EHLO` reply is an extension the client may use. With `PIPELINING` (RFC 2920) a client sends `MAIL FROM`, the `RCPT TO` lines and `DATA` in one batch; `EHLO`, `DATA`, `VRFY`, `EXPN`, `TURN`, `QUIT` and `NOOP` may only end a group, the server answers in order, and the client must check every reply. `SIZE 10240000` (RFC 1870) names the server's fixed maximum; the client adds `SIZE=` to `MAIL FROM`, and an oversized declaration gets `552`, a temporary shortage `452`, before any text is sent. `CHUNKING` (RFC 3030) adds `BDAT <octets>`: the server reads exactly that many octets, replies `250` per chunk, and `BDAT <n> LAST` ends the message, so no end-of-data dot is involved. DATA and BDAT cannot be mixed in one transaction.

go deeper

for a junior

Recall that the EHLO reply lists what the server supports, and name what PIPELINING, SIZE and CHUNKING each do in one line.

for a middle

Explain the last-command-in-group rule, the 552 against 452 answers to a SIZE declaration, and how BDAT LAST replaces the end-of-data dot.

for a senior

Use the EHLO list operationally: spot a client that pipelines without permission, a size mismatch between SIZE and the content filter, or a BDAT client a strict rule rejects.

for a principal

Weigh switching off an extension such as CHUNKING on a public MX: the protection or simplicity it buys against the throughput and compatibility legitimate senders lose.

## The EHLO reply is a capability list When a client opens with `EHLO`, the server's multiline `250` reply lists the **service extensions** it supports, one keyword per line, some with a parameter. A client may use only what it sees there. Common keywords include `PIPELINING`, `SIZE`, `CHUNKING`, `8BITMIME` (RFC 6152, which adds `BODY=8BITMIME` to `MAIL FROM`), `SMTPUTF8` (RFC 6531, internationalized addresses) and `ENHANCEDSTATUSCODES` (RFC 2034). The keywords for upgrading to TLS and for authentication are covered with transport security and with submission. Three keywords change the shape of the dialog itself. ## PIPELINING: fewer round trips Without pipelining, every command waits for its reply, which on a slow link means one round trip per recipient. RFC 2920 lets a client send commands in **groups**: - `RSET`, `MAIL FROM` and `RCPT TO` can appear anywhere in a group; - `EHLO`, `DATA`, `VRFY`, `EXPN`, `TURN`, `QUIT` and `NOOP` can only be the **last** command of a group, because their outcome changes the state the client must react to; - the message text may be the first item of a group, so the next transaction's `RSET`/`MAIL FROM` can ride with the previous message's data. The server MUST answer in the order the commands arrived and SHOULD give a positive reply to `DATA` only if at least one recipient was accepted. The client MUST check **every** status: it cannot assume `DATA` will fail just because all `RCPT TO` lines did, and it pairs replies with commands by counting them, never by matching code or text. Postfix's `smtpd_forbid_unauth_pipelining` (default `yes` from Postfix 3.9) disconnects a client that pipelines when it was not allowed to, with `554 5.5.0 Error: SMTP protocol synchronization`. ## SIZE: refuse a large message before it is sent RFC 1870 has the server advertise `SIZE`, optionally with its **fixed maximum message size** in octets, for example `250-SIZE 10240000`. The client declares an estimate on the `MAIL` command: 1. `C: MAIL FROM:<[email protected]> SIZE=48213` 2. the server replies `250` if it can take a message of that size; 3. `552` if the declaration exceeds the fixed maximum: a permanent answer, so the client should not requeue the message for that server; 4. `452` if it lacks resources now but may later: the client tries again. The size counts the octets sent after `354`, including the `CR LF` pairs but not the terminating dot or the stuffing dots. A `250` to the declaration is not a guarantee, and a server can still refuse a message larger than declared once it arrives. Postfix's `message_size_limit` defaults to `10240000` bytes. ## CHUNKING and BDAT: counted data `DATA` ends at a line holding a single dot, so both sides scan the text for that line and stuff leading dots. RFC 3030's `CHUNKING` extension replaces this with **counted chunks**: - `BDAT <chunk-size>` is followed immediately by exactly that many octets; the server replies `250` when it has them all; - `BDAT <chunk-size> LAST` marks the final chunk, and its size may be zero; - a `BDAT` after `BDAT ... LAST` gets `503`, and so does a `DATA` after a `BDAT` in the same transaction, though both may be used in one session; - after a `4xx` or `5xx` to a `BDAT`, the client MUST NOT send more chunks, and `RSET` clears the transaction; - text sent with `BDAT` MUST still be in canonical form, lines ending in `CR LF`. `CHUNKING` is also the base for `BINARYMIME`, which lets binary content travel without base64. ## Side by side | Keyword | RFC | What the client gains | Replies to know | |---|---|---|---| | `PIPELINING` | 2920 | fewer round trips per transaction | one reply per command, in order | | `SIZE` | 1870 | early refusal of a message that is too large | `552` permanent, `452` temporary | | `CHUNKING` | 3030 | counted chunks, no dot scanning | `250` per chunk, `503` for bad sequence | ## What an operator controls - **Which keywords are offered.** Postfix's `smtpd_discard_ehlo_keywords` removes keywords from the `EHLO` reply for every client, and `smtpd_discard_ehlo_keyword_address_maps` does it per client address. The Postfix advice of December 2023 for the SMTP smuggling problem was to discard `chunking` as a short-term workaround. - **The size limit** advertised by `SIZE` and enforced after `DATA`. - **How strictly pipelining rules are enforced**, which also exposes clients that ignore the extension list.

  • Why must DATA be the last command in a pipelined group?
    Because its reply decides what the client does next: a `354` means send the message text, while `503` or `554` means stop. RFC 2920 lists `DATA` with `EHLO`, `VRFY`, `EXPN`, `TURN`, `QUIT` and `NOOP` as commands that change state, so the client sends nothing after them in a group until their reply arrives.
  • A server advertised SIZE and answered 250 to MAIL FROM with SIZE=. Can the message still be rejected for size?
    Yes. RFC 1870 says a `250` to the extended `MAIL` command is not an absolute guarantee: the client must still handle `452` and `552` after `DATA` or after the transfer, and a server may refuse a message that turns out larger than the size declared.

  • Pipelining lets the server answer commands in any order it likes.
  • A client can send PIPELINING groups to any server, advertised or not.
  • A 552 to a SIZE declaration means retry later with the same message.
  • BDAT data still ends with a line holding a single dot.
  • DATA and BDAT can be mixed within one mail transaction.