Computer Networks

SMTP

How mail moves between MTAs. Store-and-forward, MX records, and spam as an adversarial load.

Level: beginner

What is it?

Simple Mail Transfer Protocol (SMTP) transfers email between mail clients and mail transfer agents and between mail servers. It is a store-and-forward protocol: a server may accept a message for delivery and attempt onward transfer later.

Why does it matter?

Email crosses independently operated domains, so the system must route messages, queue temporary failures, authenticate senders where possible, and mitigate spam and abuse.

Mental model

An SMTP server accepts a message envelope and content, then relays it toward the recipient domain's mail server. Acceptance means responsibility for further delivery under the service contract, not proof the message reached the inbox.

How it works

  • DNS MX records identify mail exchangers for a recipient domain; fallback behavior and DNS rules matter when no MX exists.
  • SMTP uses commands and status replies such as EHLO, MAIL FROM, RCPT TO, DATA, and QUIT.
  • STARTTLS or implicit TLS protects a connection when correctly negotiated, while SMTP AUTH authenticates a submitting client.
  • SPF, DKIM, and DMARC address different aspects of domain authorization, message signing, and policy/reporting.
  • Mail servers queue messages and retry temporary failures; permanent failures generally produce a bounce or status report.

Steps

  • A sender submits mail to an authenticated submission server.
  • The sender domain or sending MTA resolves the destination domain's mail exchanger.
  • The sending MTA opens SMTP, negotiates capabilities/TLS, and submits envelope plus message data.
  • The receiving MTA accepts or rejects the message, then local policy and filtering determine eventual mailbox delivery.

Real-world usage

  • Diagnosing failed delivery and SMTP authentication problems.
  • Understanding MX, SPF, DKIM, DMARC, queues, and bounces.

Common mistakes

  • Assuming SMTP acceptance guarantees inbox placement.
  • Confusing the SMTP envelope sender with the From header shown to the user.
  • Assuming TLS alone proves that the visible From domain is authorized.

Interview questions

What is the role of an MX record?

It identifies mail servers responsible for receiving email for a domain, with preference values used to choose among records.

What does DKIM provide?

It provides a cryptographic signature over selected message content/headers so receivers can verify that the signed parts were not altered and that a signing domain took responsibility.

Prerequisites

Related concepts

Continue learning

Browse the full computer science library