DELIVTERMS: Simple Mail Transfer Protocol (SMTP)


Simple Mail Transfer Protocol (SMTP) is the lingua franca used by mail servers to communicate with each other, in the process of sending and receiving email messages.

Here's a greatly oversimplified bullet-point explanation of how the email sending and receiving process works when you compose and send an email message in your favorite webmail provider like Gmail to send a message to a friend who uses a Yahoo Mail account:
  1. You open Gmail, click on compose, fill in message contents and recipient info, and hit send.
  2. The email message you've created is handed off to one of Gmail's outbound email servers (also called mail transfer agents or MTAs).
  3. Knowing that you've addressed your email message to an email account at yahoo.com, Gmail's MTA looks up the MX record in DNS to figure out where to attempt to connect to, what Yahoo Mail MTA, to deliver the mail.
  4. The Gmail MTA handling your message connects to one of Yahoo Mail's MTAs, knowing where to attempt this connection based on the DNS lookup above.
  5. The Gmail and Yahoo mail servers communicate using SMTP (well, actually, via ESMTP, the Extended Simple Mail Transfer Protocol, which allows for encryption and other modern feature add-ons to SMTP).
  6. Yahoo answers with an SMTP banner, which tells the Gmail MTA that the Yahoo server is alive and ready to take commands.
  7. The Gmail server literally says "hello" to start off an interactive conversation. (HELO or EHLO, EHLO meaning "I speak Extended SMTP.")
  8. Gmail communicates to Yahoo Mail that they have a message to deliver to person X at Yahoo.
  9. Yahoo's MTA responds with a great, OK, hand it off to me (assuming the address is valid).
  10. Gmail transmits the message to Yahoo Mail.
  11. The Gmail MTA says "QUIT" to say goodbye to Yahoo Mail's MTA, indicating that we're all done.
  12. Connection is closed, Gmail is all done.
  13. Yahoo Mail takes the email message and drops it into the inbox of the correct Yahoo user. (Or into the spam folder, if they believe it to be spammy.)
  14. Your friend is now able to find your email message in their Yahoo account.
It obviously gets a bit more complicated at scale, or if messages are rejected, or for other reasons. I've glossed over quite a few bits here for simplicity's sake.

SMTP is somewhat human readable (not only do servers say hello to each other, they also say OK in response to various commands to let you know that everything is copacetic), and there are various tools that help you view, trace and troubleshoot SMTP connections as part of troubleshooting email deliverability issues. My favorite is SWAKS.

And now you know: When people talk about SMTP, they're talking about internet email, and usually talking about the communication that allows mail servers to communicate with each other to transmit and receive email messages.

SMTP was originally defined in RFC 821 (published in 1982) and the specification has been updated and extended numerous times, including in RFC 5321.
Post a Comment

Comments