Cluster
The email RFCs, explained
Email rests on two separate ideas: what a message looks like, and how it travels. RFC 5322 defines the message, its headers, the blank line and the body. RFC 5321, better known as SMTP, moves it between servers. Almost every email misunderstanding comes from confusing those two.
The message format has a lineage rather than a single document. RFC 822 wrote it down first, in 1982, and gave email its header block, its blank-line rule and the local-part@domain address. RFC 2822 modernised that in 2001, most visibly by insisting the year be four digits. RFC 5322 is the current edition, and the one new code should target. All three describe the same shape; only the paperwork changed.
Transport is the other half. RFC 5321 is the short conversation two mail servers have to hand a message along: EHLO, MAIL FROM, RCPT TO, DATA, QUIT. Crucially, the MAIL FROM and RCPT TO of that conversation are the envelope, and they are what servers actually deliver by. The From and To you read are text inside the message. They often differ, and every interesting thing about email delivery, mailing lists, BCC and forged spam, lives in that gap.
A rule of thumb that resolves most confusion: if it is a command in a conversation, it is 5321; if it is a line inside the message, it is 5322.
Start here
Four pages, in the order that makes the picture come together fastest:
-
RFC 5322 Today's format
The anatomy of an email, and why the From line can lie.
The current definition of what an email message looks like. Start here if you only read one.
-
RFC 5321 The transport
The protocol that actually delivers your email.
SMTP: how a message actually travels between servers, and why the envelope is not the From header.
-
RFC 822 Where it began
The shape of every email, defined in 1982.
The 1982 original that set the shape. Also the source of the phrase "RFC 822 name" you meet in TLS certificates.
-
RFC 2822 The in-between edition
The email format's in-between edition.
The 2001 revision between 822 and 5322. Obsolete, but still cited across older libraries and code comments.