SMTP Basics

What SMTP is

The Simple Mail Transfer Protocol (SMTP) is the backbone of email. It is the standard that lets mail move between different servers and networks. Think of it as the postal service of the internet: when you send a message, your client hands it to an SMTP server, that server figures out how to route it, the message travels across the internet to the recipient’s mail server, and that server drops it into the inbox.

Just as postal workers follow set procedures to sort and deliver physical mail, SMTP servers follow standardized commands and responses.

The pieces involved

A message passes through several agents on its journey:

  • MUA (Mail User Agent): your email client, such as Gmail’s web app or Outlook.
  • MSA (Mail Submission Agent): receives mail from clients and verifies the addresses.
  • MTA (Mail Transfer Agent): processes and transfers mail between servers.
  • MDA (Mail Delivery Agent): delivers the message into the recipient’s mailbox.

SMTP itself comes in a few flavors depending on the role a server plays: originating (introducing mail to the internet), delivery (receiving mail for a local mailbox), relay (passing mail along unchanged), and gateway (passing mail and possibly transforming it).

The extensions worth knowing

  • ESMTP (Extended SMTP) adds features to the original protocol. It opens a session with EHLO instead of HELO and supports extra parameters.
  • SMTPS secures the connection with TLS or SSL, encrypting the message during transmission.
  • SMTP-AUTH requires a client to log in with a username and password before sending, which stops strangers from using your server as an open relay.

SMTP is a conversation

Under the hood, SMTP is a back-and-forth of commands and numeric responses, almost like dialogue:

Client: HELO example.com
Server: 250 Hello example.com, pleased to meet you
Client: MAIL FROM: <[email protected]>
Server: 250 OK
Client: RCPT TO: <[email protected]>
Server: 250 OK
Client: DATA
Server: 354 Start mail input; end with <CRLF>.<CRLF>
Client: [Email content...]
Client: .
Server: 250 OK
Client: QUIT
Server: 221 Bye

Each step has a clear role: HELO/EHLO introduces the sending server, MAIL FROM names the sender, RCPT TO names the recipient, DATA carries the message body, and QUIT ends the session. This rigid structure is what makes delivery reliable across wildly different systems.

The important thing to notice for later chapters: nothing in this conversation proves the sender is who they claim to be. MAIL FROM is whatever the client types. That gap is what authentication, the next chapter, exists to close.

Next