D. J. Bernstein
Internet mail
SMTP: Simple Mail Transfer Protocol

The EHLO verb and SMTP extensions

EHLO is just like HELO except that the server's response text provides computer-readable information about the server's abilities.

Here is what happens if the server accepts EHLO (required code 250). On the first response line, the text begins with the server's name. On each response line past the first, the text is an extension, followed optionally by a space and an argument, followed optionally by a space and another argument, etc.

The extension is a nonempty string of letters, digits, and hyphens. Each argument is a nonempty string of graphical ASCII characters.

A rather extreme example:

     220 size.does.matter.af.MIL (More ESMTP than Crappysoft!)
     EHLO heaven.af.mil
     250-size.does.matter.af.MIL offers FIFTEEN extensions:
     250-8BITMIME
     250-PIPELINING
     250-DSN
     250-ENHANCEDSTATUSCODES
     250-EXPN
     250-HELP
     250-SAML
     250-SEND
     250-SOML
     250-TURN
     250-XADR
     250-XSTA
     250-ETRN
     250-XGEN
     250 SIZE 51200000
The last extension here is SIZE, with argument 51200000; the other extensions do not have arguments.

Extension semantics

RFC 1869 prohibits all extensions except (1) extensions defined by the IETF and (2) extensions beginning with the letter X. However, some servers use private extensions that do not begin with the letter X. In any case, clients must be prepared for unrecognized extensions; the IETF may define new extensions at any time.

Extensions generally apply to a single connection. If the client reconnects to the same host a minute later, it may find a completely different list of extensions.

Extensions are supposed to be interpreted without regard to case. In practice extensions are always sent in uppercase. I don't know if there are clients that have trouble with lowercase.

Using EHLO

If the server supports EHLO, the client can use EHLO instead of HELO as its first request. (Note that sendmail's decision of whether to use HELO or EHLO depends on the server's greeting.)

On the other hand, if the server does not support EHLO, and the client sends EHLO, the server will reject EHLO. The client then has to fall back to HELO.

There are a few servers that disconnect when they see EHLO. If the client finds that neither EHLO nor HELO was accepted, for example because the connection was closed, then it has to make a new connection and start with HELO.

Extension name index

The following list shows all the extensions that I've seen from SMTP servers.
8BITMIME
ATRN
AUTH
AUTH=LOGIN
BINARYMIME
CHECKPOINT
CHUNKING
DSN
ENHANCEDSTATUSCODES
ENHANGEDSTATUSCODES [sic]
ETRN
EXPN
HELP
ONEX
PIPELINING
RSET
SAML
SEND
SIZE
SOML
TIME
TLS
TURN
VERB
VRFY
X-EXPS
X-EXPS=LOGIN
X-LINK2STATE
X-RCPTLIMIT
X-TURNME
XADR
XAUD
XDSN
XEXCH50
XGEN
XONE
XQUE
XREMOTEQUEUE
XSTA
XTRN
XUSR
XVRB
Thanks to Peter Bieringer for reports.