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: