The SMTP conversation
Start an SMTP session
Read the server greeting and use EHLO to identify a client and discover supported SMTP extensions.
8 minute lesson
An SMTP server speaks first with a 220 greeting. The client then introduces itself with EHLO and a domain name.
A successful EHLO reply begins with 250. Additional 250- lines advertise extensions such as SIZE, STARTTLS, AUTH, and 8BITMIME.
S: 220 mail.example.net ready
C: EHLO client.example.org
S: 250-mail.example.net
S: 250-SIZE 52428800
S: 250 STARTTLS
Use the advertised capabilities instead of assuming every server supports the same extensions.
The greeting and EHLO establish session state. A multiline reply uses a hyphen after the code until the final line:
S: 250-mail.example.net
S: 250-PIPELINING
S: 250-SIZE 52428800
S: 250 STARTTLS
The last line uses a space, so the reply is complete. A client that stops reading after the first line can miss a size limit or try authentication before the server advertises it.
If the server rejects EHLO, an SMTP client can try HELO for the base protocol. It then loses extension negotiation. Submission software should not silently continue if the message requires an extension such as SMTPUTF8.
After STARTTLS, send EHLO again. Capabilities advertised before encryption are discarded, and the protected session may advertise a different set, including authentication mechanisms.
Annotate the transcript above. Mark the server identity, every extension, the final line, and the command that must be repeated after a TLS upgrade.
Lesson completed