Inspect text protocols
Read an SMTP greeting
Inspect a plaintext SMTP greeting and EHLO reply without authenticating, relaying mail, or exposing credentials.
8 minute lesson
SMTP is another line-oriented text protocol, and unlike HTTP, the server speaks first. In an authorized mail lab, connect to the SMTP server port:
telnet mail.lab.test 25
A server normally starts with a 220 greeting before you type anything:
220 mail.lab.test ESMTP Postfix
Send an EHLO name, read the advertised extensions, then quit:
EHLO client.lab.test
QUIT
A real exchange looks like this:
220 mail.lab.test ESMTP Postfix
EHLO client.lab.test
250-mail.lab.test
250-PIPELINING
250-SIZE 10240000
250-STARTTLS
250 SMTP UTF8
QUIT
221 2.0.0 Bye
Every server reply starts with a three-digit code. 220 is the greeting, 250 means success, 221 says goodbye. Your client software can branch on the code without parsing the human-readable text after it.
Reading the multiline reply
Look closely at the EHLO response. A multiline EHLO reply uses 250- on every line except the last, which uses 250 with a space. The hyphen means “more lines follow with this same code”. The space means “this is the final line”.
This small detail demonstrates how a text protocol defines message boundaries inside a TCP stream. TCP will not tell the client where the reply ends. The protocol grammar does, one character at a time. A client that stops reading after the first 250- line has a framing bug, and it is exactly the kind of bug you catch by reading the raw exchange like this.
The extension list is the useful diagnostic output here. STARTTLS tells you the server can upgrade to an encrypted connection. SIZE tells you the maximum message it accepts.
Where to stop
Stop before AUTH and do not send a password. Everything you typed in this session crossed the network in plaintext, and credentials must never travel that way.
Modern submission on port 587 commonly requires TLS before authentication, so a plaintext session cannot get far anyway. Use a TLS-aware mail client or openssl s_client -starttls smtp -connect mail.lab.test:587 when you need to inspect that path. You get the same readable dialogue, after encryption is in place.
Lesson completed