[ Transport security ]

MTA-STS policy syntax: version, mode, MX and max_age

Validate the policy body separately from the discovery TXT record, and preserve the meaning of each required field.

By the EmailAuth research team

[ Key points ]

  • DNS discovery and the HTTPS policy use different formats.
  • Protocol first-value parsing differs from stricter duplicate-field publication lint.
  • A valid policy file does not prove valid SMTP delivery.
On this page

An MTA-STS deployment has two distinct formats. DNS advertises v=STSv1; id=20261107A, while HTTPS serves a line-oriented policy. Putting the DNS string in the policy file, or the policy body in DNS, does not create a working deployment.

Build the minimal policy deliberately

References: RFC 8461 §3.2.

A testing example for the reserved domain example.com is:

version: STSv1
mode: testing
mx: mx1.example.net
max_age: 86400

Each field is on its own line. Serve these as plain text at https://mta-sts.example.com/.well-known/mta-sts.txt. This is an illustrative configuration, not a claim that those hosts run mail services.

Version, mode and max_age are required. At least one mx line is required except for mode none. Allowed modes are testing, enforce and none. max_age is a non-negative integer number of seconds, written with one to ten digits, with a maximum value of 31557600. One day in this example is an observation-stage choice, not a universally recommended production lifetime; longer lifetimes improve resistance to interrupted policy refresh but lengthen stale-policy exposure.

Keep parser behavior distinct from editorial lint

References: RFC 8461 §3.2.

RFC 8461 section 3.2 permits LF or CRLF line endings. Required field names and specified values are case-sensitive. Multiple MX patterns belong on separate mx lines, not a comma-separated list. Internationalized names use their ASCII A-label form.

A conforming parser ignores unknown fields and ignores subsequent copies of a non-repeated field after its first occurrence. Therefore mode: testing followed by mode: enforce does not reliably enforce anything: the first mode controls under the specification. A deployment linter should reject that ambiguity for publication even though the protocol defines how to parse it. Document this stricter editorial rule instead of claiming all duplicate fields make the protocol policy invalid.

Reproduce the critical distinctions

Create a UTF-8 file containing the four-line example. Check that splitting it into lines yields four key/value pairs and one MX value. Add a second mx line and expect two allowed hosts. Add a second mode line and compare first-value parsing with the stricter publication lint. Replace max_age with -1, 31557601 and a word, and expect each to fail the range or numeric check.

This review package includes an executable bounded fixture for the first-value, numeric-boundary and wildcard cases. It is not a complete ABNF parser or a production MTA. The newly recorded offline run passes those limited checks. Passing it proves the stated local comparisons, not DNS discovery, HTTPS certificate validation or SMTP delivery.

Publish only after the full route agrees

References: RFC 8461 §3.3, RFC 8461 §4.

Retain the exact file bytes and their hash, the discovery TXT value, the MX answers and the intended cache lifetime. Fetch the fixed URL without following redirects and inspect its body. Then verify every advertised MX's STARTTLS and certificate identity before choosing enforce. A syntactically valid file cannot compensate for a missing MX pattern or an invalid receiving certificate.

Retained historical evidence and remaining scope

The following is the retained 7 November 2026 lab record, inspected but not rerun as a network experiment for this review. New offline fixture execution is recorded separately.

The expanded isolated lab parsed actual policy-body text. A four-line enforce policy produced an enforce decision object with the allowed old MX and max_age 86400. Bodies with no MX, max_age 31557601 or STSv2 were rejected. A duplicate second mode retained the first testing value. After a real loopback STARTTLS handshake failed hostname verification, the restricted decision engine produced allow_despite_sts_failure for testing and do_not_deliver_to_candidate for enforce. These are captured fixture decisions, not observations of a production MTA queue. The parser intentionally supports only the ASCII cases listed here and is not a complete ABNF implementation.

[ Takeaway ]

A valid policy file does not prove valid SMTP delivery.

[ By role ]

What this means for you

Choose your role for practical next steps.

IT / Mail Admin

Check grammar and delivery separately

A clean parse does not prove the receiving route works.

Next steps

  1. Lint required fields and ranges.
  2. Fetch the exact URL.
  3. Test each advertised MX.

CISO / SecOps

Reject publication ambiguity

Duplicate fields can hide a different effective mode from the one intended.

Next steps

  1. Reject ambiguous duplicate fields in publication.
  2. Review wildcard scope.
  3. Separate syntax evidence from transport evidence.

Founder / Non-technical

Approve a deliberate policy

The mode and lifetime are operational decisions, not just text fields.

Next steps

  1. Approve the intended mode.
  2. Name the policy owner.
  3. Keep a rollback copy.

[ FAQs ]

Frequently asked questions

Is STSv1 the same spelling in both places?

Yes, but DNS uses v=STSv1 while the file uses version: STSv1.

RFC 8461 §3.1 RFC 8461 §3.2

Can the mode be uppercase?

Use the specified lowercase testing, enforce or none values.

RFC 8461 §3.2

Are LF line endings allowed?

Yes. The policy grammar accepts LF or CRLF.

RFC 8461 §3.2

Can I list several MX names on one line?

Use a separate mx line for each allowed pattern.

RFC 8461 §3.2

What does max_age measure?

The maximum policy cache lifetime in seconds from the sender’s fetch.

RFC 8461 §3.2

Does a later mode override the first?

No. The protocol ignores subsequent copies of non-repeated fields.

RFC 8461 §3.2

Are unknown fields always errors?

No. Syntactically valid unknown fields are ignored by protocol parsers.

RFC 8461 §3.2

Does valid syntax prove delivery works?

No. Discovery, HTTPS and each SMTP route still need checking.

RFC 8461 §3.3 RFC 8461 §4

[ Sources ]

Sources

  1. RFC 5890

    Sections §2.3.2.1

  2. RFC 8461

    Sections §3.1 · §3.2 · §3.3 · §4

[ Glossary ]

Glossary

Policy body
The HTTPS-hosted line-oriented MTA-STS configuration.

RFC 8461 §3.2

max_age
Maximum policy cache lifetime in seconds.

RFC 8461 §3.2

A-label
A validated ASCII-compatible IDNA label, rather than any arbitrary Punycode-looking string.

RFC 5890 §2.3.2.1

Enterprise provenance

Why top financial institutions and governments retired their email security dashboards.

Traditional email authentication platforms sell you a dashboard and ask your engineers to do the labour. In high-stakes environments, manual oversight means delayed enforcement, configuration drift and unmonitored shadow domains.

EmailAuth is the agentic email provenance platform. Our agents enforce p=reject, keep third-party senders aligned and move your domains to full RFC 9989 compliance, the new DMARC standard,, with human-in-the-loop auditability.

Governments Large enterprises Tier-1 financial institutions

SaaS · Dedicated tenancy · Air-gapped on-prem · BYOK encryption

Knowledge Base