Some time ago, I came up with a bar joke involving SMTP. Since I need to explain it a couple of times, I thought I just write it down as a blog post for future reference.
The joke goes like this (as a tweet):
A man walks into an SMTP bar. He says, "EHLO guys!".
— Ariya Hidayat (@AriyaHidayat) March 13, 2014
The key thing here is the EHLO part. To explain this, let me show you a typical chatting between an SMTP server (e.g. from your mail provider) and an SMTP client (e.g. your email application). If you want to follow along, there is a nice trick. Sign up at Mailtrap for a test account (you can authenticate using your Github credential) and you will have a test server to play with.
Start by connecting to the server using
telnet mailtrap.io 2525 Trying 22.214.171.124... Connected to mailtrap.io. Escape character is '^]'. 220 mailtrap.io ESMTP ready
At this moment, you are supposed to greet the server (see RFC 821, Section 3.5 on Opening and Closing) using the
HELO mailtrap.io 250 mailtrap.io
If you carefully read the above RFC 821, it is obvious that SMTP commands are 4-letter words. Thus,
NOOP is to do nothing,
HELP for showing up some instructions, and so on.
As SMTP grows in functionality, an extension mechanism is established so that the client recognizes certain extra features of the server and perhaps would like to leverage them. Rather than inventing a completely different opening command,
EHLO is introduced (see RFC 5321, Section 3.2 on Client Initialization). This new command let the client and server know about each other’s privileged status. For example, running EHLO on Mailtrap gives us:
EHLO mailtrap.io 250-mailtrap.io 250-SIZE 5242880 250-PIPELINING 250-ENHANCEDSTATUSCODES 250-8BITMIME 250-DSN 250-AUTH PLAIN LOGIN CRAM-MD5 250 STARTTLS
which basically lists some service extensions supported by Mailtrap’s SMTP server.
Practically all modern email clients prefer to use EHLO instead. It is quite widespread and hence, the bar joke and the EHLO style of greeting. That was fun, right?