RFC 5321: Simple Mail Transfer Protocol

The authoritative SMTP standard defining the full MTA-to-MTA command sequence.
Alaa
By Alaa
SMTPedia documents email infrastructure end to end: SMTP standards from the RFC archive, delivera...
11 min read Updated Jul 22, 2026 348 views
RFC 5321
Simple Mail Transfer Protocol
Current standard
Domain
SMTP
Published
October 2008
Obsoletes
RFC 2821, RFC 821
SMTP relevance
foundational
↗ Read on rfc-editor.org

What this RFC defines

RFC 5321 is the current SMTP standard. It defines the complete protocol for transferring email between servers: the TCP session lifecycle, the EHLO greeting, the MAIL FROM and RCPT TO envelope commands, the DATA transaction, and the QUIT teardown. Every mail server on the internet, whether Postfix, Exchange, or SendGrid, implements this document.

Where you see it in practice

The three-digit reply codes in your bounce messages (220, 250, 421, 450, 550, 554) are defined here. When a receiving server rejects your message with “550 5.1.1 User unknown”, that code structure traces back to RFC 5321 section 4.2. The requirement that your EHLO hostname match a valid PTR record (section 2.3.5) is why missing reverse DNS causes deliverability issues with strict MTAs.

How it connects to other RFCs

RFC 5321 supersedes RFC 2821 (2001) and RFC 821 (1982). It works alongside RFC 5322 (message format), RFC 4954 (SMTP AUTH), RFC 3207 (STARTTLS), and RFC 6409 (port 587 submission). These five documents form the core SMTP stack. Extension RFCs like RFC 6531 (internationalization) and RFC 1870 (SIZE) build on top of RFC 5321 without replacing it.

Current status

RFC 5321 is the current standard, published October 2008 and maintained by the IETF. No successor is planned. Extensions to SMTP are defined as separate RFCs that add new capabilities to RFC 5321’s base, rather than replacing the document itself.

Implementation across major MTAs

Every production mail transfer agent implements RFC 5321. Postfix, Exim, Sendmail, and Microsoft Exchange are the four dominant open-source and enterprise MTAs, and each conforms to the base protocol described in the document, with minor policy differences in areas the RFC leaves as SHOULD or MAY. Cloud services like Amazon SES, SendGrid, Mailgun, Postmark, and SparkPost also speak RFC 5321 on their outbound relays and accept it on their inbound MX endpoints. The universality of RFC 5321 conformance is why interoperability at the SMTP layer is essentially a solved problem in 2026.

Common misconceptions

Three misconceptions recur frequently. First, RFC 5321 does not mandate authentication; SMTP AUTH is defined in RFC 4954 as an extension. A vanilla RFC 5321 conversation does not require the sender to authenticate, which is why open relays existed for decades before operational best practice mandated closing them. Second, RFC 5321 does not require TLS; STARTTLS is defined in RFC 3207 as an optional extension. RFC 8314 later declared cleartext obsolete for submission, but RFC 5321 itself remains protocol-agnostic on transport security. Third, the SIZE line in an EHLO response is a hint, not a hard commitment; a receiving server can accept a message larger or smaller than the advertised limit depending on per-recipient policy.

Testing conformance

The classic conformance check is a telnet session to port 25 (or 587 for submission), where you type each command manually and verify that the responses follow the reply-code grammar. Automated conformance is typically done with tools like swaks, smtpm, or the Postfix smtp-source utility. For inbound conformance, the receiving MTA logs should show your EHLO greeting, MAIL FROM and RCPT TO exchanges, and the final DATA acceptance. Any of these steps rejecting valid input, or accepting clearly invalid input, indicates a conformance issue.

Quick Reference

RFC 5321 (October 2008) is the current Simple Mail Transfer Protocol standard. It defines the complete server-to-server email transfer protocol: TCP session, EHLO handshake, MAIL FROM and RCPT TO envelope, DATA transaction, three-digit reply codes, and QUIT teardown. Obsoletes RFC 2821 (2001) and RFC 821 (1982). Works alongside RFC 5322 (message format), RFC 3207 (STARTTLS), RFC 4954 (SMTP AUTH), and RFC 6409 (message submission on port 587). No successor planned; extensions are separate RFCs that build on this base.

RFC 5321 at a glance

AspectDetail
PurposeServer-to-server email transfer protocol
TransportTCP, typically port 25 (server-to-server) or 587 (client submission per RFC 6409)
Session modelStateful command/response with three-digit reply codes
Core commandsEHLO, MAIL FROM, RCPT TO, DATA, QUIT (plus RSET, NOOP, VRFY, EXPN, HELP)
Reply code structure3-digit numeric: first digit is severity class, remaining digits refine
Extension mechanismEHLO response advertises supported extensions per RFC 1869
PublishedOctober 2008 (obsoletes RFC 2821, RFC 821)
StatusCurrent standard; no successor planned

Complete SMTP command reference

RFC 5321 defines a small set of commands that flow between client (sending MTA) and server (receiving MTA). Every SMTP conversation follows the same pattern: server greeting, EHLO exchange, envelope commands, DATA, and QUIT.

CommandPurposeExampleSection
HELOLegacy greeting (RFC 821), rarely used todayHELO mail.example.com4.1.1.1
EHLOExtended greeting, triggers capability advertisementEHLO mail.example.com4.1.1.1
MAIL FROMEnvelope sender (Return-Path)MAIL FROM:<sender@example.com>4.1.1.2
RCPT TOEnvelope recipient (one per command)RCPT TO:<user@example.com>4.1.1.3
DATABegin message body transfer, ends with . on line aloneDATA4.1.1.4
RSETAbort current transaction, keep connectionRSET4.1.1.5
VRFYVerify address exists (often disabled for anti-harvesting)VRFY user@example.com4.1.1.6
EXPNExpand mailing list (usually disabled)EXPN list@example.com4.1.1.7
HELPRequest server-side help textHELP4.1.1.8
NOOPNo operation, keep-aliveNOOP4.1.1.9
QUITEnd sessionQUIT4.1.1.10

SMTP reply code structure

Every SMTP command produces a three-digit reply code. The first digit indicates the severity class; the second digit categorizes the source; the third digit adds specificity. Modern deployments extend this with enhanced status codes per RFC 3463 (see also DSN parsing guide for practical parsing).

First digitClassMeaningCommon examples
2xxSuccessCommand accepted and completed220 Ready, 221 Bye, 250 OK, 251 User forwarded
3xxIntermediateAwaiting more input from client354 Start mail input (after DATA)
4xxTransient failureRetry later, may succeed421 Service unavailable, 450 Mailbox busy, 451 Local error
5xxPermanent failureDo not retry, address the underlying issue550 Mailbox unavailable, 551 User not local, 552 Storage full, 553 Bad address, 554 Transaction failed

A complete SMTP dialogue

Full SMTP session (client → server flow) S: 220 mx.example.com ESMTP Postfix C: EHLO mail.sender.com S: 250-mx.example.com Hello mail.sender.com [192.0.2.10] S: 250-SIZE 52428800 S: 250-8BITMIME S: 250-STARTTLS S: 250-ENHANCEDSTATUSCODES S: 250-PIPELINING S: 250-DSN S: 250-CHUNKING S: 250 SMTPUTF8 C: MAIL FROM:<alice@sender.com> S: 250 2.1.0 Ok C: RCPT TO:<bob@example.com> S: 250 2.1.5 Ok C: DATA S: 354 End data with <CR><LF>.<CR><LF> C: From: Alice <alice@sender.com> C: To: Bob <bob@example.com> C: Subject: Test message C: C: Hello Bob, this is a test. C: . S: 250 2.0.0 Ok: queued as ABC123 C: QUIT S: 221 2.0.0 Bye

Common ESMTP extensions

The EHLO response advertises server capabilities as extensions per RFC 1869. Modern SMTP servers implement dozens of extensions; the essentials are listed below.

ExtensionAdvertised asDefined inPurpose
SIZESIZE 52428800RFC 1870Advertise maximum message size in bytes
8BITMIME8BITMIMERFC 6152Accept 8-bit MIME content without encoding
STARTTLSSTARTTLSRFC 3207Upgrade cleartext connection to TLS
AUTHAUTH LOGIN PLAINRFC 4954Client authentication (list of mechanisms)
PIPELININGPIPELININGRFC 2920Batch multiple commands without waiting for reply
ENHANCEDSTATUSCODESENHANCEDSTATUSCODESRFC 2034Return X.Y.Z codes alongside 3-digit codes
DSNDSNRFC 3464Support delivery status notifications
CHUNKINGCHUNKINGRFC 3030Transfer message body in binary chunks (BDAT)
SMTPUTF8SMTPUTF8RFC 6531Support internationalized mailbox names
BINARYMIMEBINARYMIMERFC 3030Accept binary MIME parts (requires CHUNKING)

Common SMTP implementation pitfalls

EHLO hostname does not resolve or does not match PTR. RFC 5321 section 2.3.5 requires the EHLO argument to be a fully-qualified hostname. Strict receivers cross-check that reverse DNS (PTR) of the sending IP matches the EHLO hostname (FCrDNS). Mismatch causes rejections like 550 Access denied: Invalid HELO name. Fix: publish PTR matching your EHLO hostname (see PTR and rDNS records guide).
MAIL FROM with quoted display name or CFWS. The MAIL FROM envelope uses simple mailbox format, not the full RFC 5322 mailbox with display name. Sending MAIL FROM:<"Sender Team" <team@example.com>> is a syntax error. Use only the bare address: MAIL FROM:<team@example.com>. Display names go in the From header inside DATA.
Retrying 5xx responses as though they were transient. RFC 5321 section 4.5.4 mandates that 5xx is permanent. Retrying a 5xx bounce violates protocol semantics and damages sender reputation because receivers track how many times you send to known-bad addresses (see hard bounce vs soft bounce guide).
Ignoring TIMEOUT values in section 4.5.3.2. RFC 5321 specifies timeout values for each phase of the SMTP conversation: 5 minutes for initial greeting, 5 minutes for MAIL/RCPT/DATA acknowledgments, 10 minutes for DATA send. Aggressive short timeouts cause premature disconnects with slow receivers; long timeouts hold sockets open unnecessarily. Follow the spec.
Not handling BDAT after advertising CHUNKING. Some servers advertise CHUNKING in EHLO but reject BDAT commands in practice. If you implement CHUNKING support on the client side, test against real receivers; fall back to DATA on BDAT errors.

Migration from RFC 2821 to RFC 5321

AspectRFC 2821 (2001)RFC 5321 (2008)Impact if code targets 2821
Core protocolComplete SMTPIdentical semantics with clarificationsNone
Reply code registryEnumerated in RFCDelegated to IANAUpdate reference; no code change
Address literal syntaxIPv4 only in bracket formAdds IPv6 with IPv6: tagUpdate address parser for IPv6
Errata integrationSeparate errataErrata integrated in main textNone
InternationalizationASCII onlyASCII base with pointer to RFC 6531 for SMTPUTF8None (extension is separate RFC)
SIZE recommendationsSection 3.1.1Clarified in section 4.5.3.1.5Review SIZE handling logic
Should you migrate? Yes. RFC 2821 is obsolete; all references and implementations should target RFC 5321. In practice, code correctly implementing RFC 2821 already works fine against RFC 5321 peers because the protocol is backward compatible. The migration is primarily about documentation and reference accuracy.
Core SMTP ecosystem RFCs
  • RFC 5322: Internet Message Format (headers and body of the actual message)
  • RFC 6409: Message Submission (port 587 client-to-server distinction)
  • RFC 3207: STARTTLS extension for SMTP over TLS
  • RFC 4954: SMTP AUTH extension
  • RFC 8314: Cleartext considered obsolete for submission/access
  • RFC 6152: 8-bit MIME transport
  • RFC 1869: The EHLO extension mechanism
Report and status RFCs (built on SMTP)
Authentication and deliverability layer
SMTPedia companion guides

Frequently asked questions

What is the difference between HELO and EHLO?

HELO is the legacy greeting from RFC 821 (1982). EHLO is the extended greeting introduced in RFC 1869 and codified in RFC 5321. When a client sends EHLO, the server responds with a multi-line reply listing all supported extensions (SIZE, STARTTLS, AUTH, PIPELINING, and others). HELO produces only a single greeting line without capability information. Modern clients always send EHLO first; if the server responds with a syntax error, they fall back to HELO. In 2026, every production SMTP server supports EHLO; HELO is retained purely for backward compatibility.

Does RFC 5321 require authentication?

No. RFC 5321 defines the base SMTP protocol; authentication is a separate extension in RFC 4954. A vanilla RFC 5321 conversation does not require the client to authenticate. This is why open relays existed for decades; the protocol did not mandate closure. Modern operational best practice requires AUTH for message submission (per RFC 6409 and RFC 8314) but server-to-server relay per RFC 5321 remains authentication-optional.

Does RFC 5321 require TLS?

No. RFC 5321 is transport-security-agnostic; STARTTLS is defined as an optional extension in RFC 3207. RFC 8314 (2018) declared cleartext obsolete for message submission and access, but did not amend RFC 5321 for server-to-server relay. Practical reality in 2026: cleartext SMTP relay still occurs when both peers lack STARTTLS support, though this is uncommon at reputable providers. TLS-required policies (MTA-STS, DANE) sit on top of RFC 5321 as separate mechanisms.

What is the difference between MAIL FROM and the From header?

MAIL FROM is the envelope sender, a protocol-level attribute of the SMTP conversation. It becomes the Return-Path header of the delivered message and is used for bounce routing. The From header is a message-level attribute inside DATA, defined by RFC 5322, that names the visible sender to the recipient. The two can differ (a common pattern with newsletter platforms where MAIL FROM points at a bounce-processing subdomain but From displays the company brand). Anti-spoofing mechanisms like DMARC require alignment between these two identities per configured policy.

Why do some servers disable VRFY and EXPN?

Both commands allow a client to query which addresses exist on a server without sending mail. Spammers used VRFY to harvest valid addresses from target domains at scale. Modern operational best practice disables both commands on internet-facing MTAs to prevent address harvesting. RFC 5321 section 3.5.3 explicitly permits this: implementations MAY implement VRFY as a no-op returning 252 (cannot verify) to avoid disclosing address existence. Most production Postfix and Exchange deployments disable VRFY and EXPN entirely.

What happens when a message hits the SIZE limit?

If the client sent the SIZE parameter with MAIL FROM and the value exceeds the server-advertised limit, the server rejects at MAIL FROM with a 552 or 452 code before any data transfer. If the client did not declare SIZE, the server can still reject after DATA if the actual message exceeds its limit. Either path produces a bounce back to the sender. Some servers accept messages slightly over the advertised limit as a courtesy; others enforce strictly. The advertised SIZE is a hint, not a hard commitment, per RFC 5321 section 3.7.5.


About the Author

Alaa - SMTPedia author

Alaa · LinkedIn

Email infrastructure specialist with 8+ years of hands-on experience in SMTP, deliverability, and email verification. I’ve configured and troubleshot mail systems across Postfix, Exchange, and cloud relays, managed IP reputation and warmup campaigns, and built verification pipelines processing millions of addresses. My work spans DNS authentication (SPF, DKIM, DMARC, BIMI), bounce handling, blocklist monitoring, and compliance frameworks including CAN-SPAM and GDPR. I write every article on SMTPedia to give email professionals, developers, and marketers the accurate, RFC-grounded reference they need.


About SMTPedia

SMTPedia is an independent email industry reference covering SMTP, IMAP, POP3, email deliverability, marketing platforms, DNS authentication, and email verification. Every article is researched from official provider documentation, IETF RFCs, and industry best practices. Settings and configurations are verified quarterly.

We are cited as a source by ChatGPT, Microsoft Copilot, and thousands of email professionals worldwide. Learn more about our editorial process.