Inspect text protocols
Read an SMTP greeting
Inspect a plaintext SMTP greeting and EHLO reply without authenticating, relaying mail, or exposing credentials.
SMTP is another line-oriented text protocol, and it has one difference from HTTP that you notice right away: the server speaks first.
In an authorized mail lab, connect to the SMTP server port:
telnet mail.lab.test 25
Before you type anything, the server sends a 220 greeting:
220 mail.lab.test ESMTP Postfix
Now introduce yourself with an EHLO and your client’s name, read what the server advertises, then quit:
EHLO client.lab.test
QUIT
The full 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. A client program can branch on the code without parsing the human-readable text after it. The text is for you. The code is for the machine.
Reading the multiline reply
Look closely at the EHLO response. Five lines, all starting with 250. Four of them have a hyphen after the code, 250-. The last one has a space, 250 .
That single character is the framing rule. The hyphen means “more lines follow with this same code”. The space means “this is the final line”. A client reads line after line until it sees the space.
This is 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 also useful diagnostic output. STARTTLS tells you the server can upgrade to an encrypted connection. SIZE 10240000 tells you the biggest message it accepts, about 10 MB here.
Where to stop
Stop before AUTH, and never send a password. Everything you typed in this session crossed the network in plaintext, and credentials must never travel that way.
Modern mail submission on port 587 usually requires TLS before authentication anyway, so a plaintext session cannot get far. When you need to inspect that path, use a TLS-aware tool:
openssl s_client -starttls smtp -connect mail.lab.test:587
-starttls smtp makes OpenSSL do the plaintext greeting and the STARTTLS upgrade for you. Then you get the same readable dialogue, after encryption is in place.
Lesson completed