Introduction
MTA-STS lets a mail domain say that mail sent to it should be delivered over TLS to named mail servers only. The domain publishes a small
policy file, mta-sts.txt, at a fixed address; a sending mail server that honours the standard caches it. RFC 8461 defines it:
the policy is “a set of key/value pairs (similar to header fields in RFC 5322) served via the HTTPS GET method from the fixed well-known path of
.well-known/mta-sts.txt served by the Policy Host”. For the policy domain example.com the address is
https://mta-sts.example.com/.well-known/mta-sts.txt. A DNS TXT record named _mta-sts tells senders that a policy exists and
carries an id that changes when the policy does.
Structure
version: STSv1
mode: enforce
mx: mail.example.com
mx: *.example.net
mx: backupmx.example.com
max_age: 604800
This is the example of RFC 8461 section 3.2. The text is “CRLF-separated key/value pairs”; the ABNF in the same section accepts a bare line feed as well
(sts-policy-term = LF / CRLF).
| Field | Rule (RFC 8461 section 3.2 and its ABNF) |
|---|---|
version | Required once. Currently only STSv1 is supported. |
mode | Required once. enforce, testing or none. In enforce mode senders must not deliver to hosts that fail MX matching,
certificate validation or STARTTLS; in testing mode failures are reported (by senders that implement TLSRPT) but mail may still be delivered; none means the domain is treated as having no active
policy (section 5; section 8.3 uses it to remove a policy). |
max_age | Required once. How long a sender may cache the policy: a non-negative integer of seconds, 1 to 10 digits, at most 31557600. The RFC expects values in the range of weeks or greater. |
mx | Required at least once, except when mode is none. Each allowed MX host has its own line. The value is a fully specified name or a suffix prefixed by a wildcard
(*.example.net); the wildcard may only match the entire left-most label, so *.example.com matches mail.example.com but not example.com or
foo.bar.example.com (section 4.1). Internationalised names are written as Punycode A-labels. |
| other fields | Extension fields are allowed: a name of 1 to 32 letters, digits, _, - or ., and a value of visible characters. “Unknown fields SHALL be ignored.”
If a field other than mx is repeated, all entries except the first are ignored. |
When fetching, senders should check that the media type is text/plain; a suggested maximum policy size is 64 kilobytes.
In the explorer
A file named mta-sts.txt opens here when its content passes a strict test: a version: STSv1 line, a mode line with one of the three values, and most lines in
the form key: value. Any other file with that name (HTML, prose, a partial policy) opens as plain text, as before. The tree has a node for each line, with a note on every field; the Fields tab
lists them; the Problems tab and the Overview report every rule above that the file breaks (missing or repeated fields, a mode or a version that is not allowed, a max_age that is not digits
or is too large, an mx that is not a domain name or has a wildcard anywhere but the left-most label, an extension name that is not allowed, a file over 64 kilobytes). Nothing is fetched,
so the DNS record, the media type and the certificates are not checked.
Not described
Known, not yet covered
- Reference: the
_mta-stsTXT record (RFC 8461 section 3.1), TLSRPT reporting (RFC 8460), policy delegation by CNAME (section 8.2), the update and removal procedures (section 8) and certificate validation (section 4.2) are named but not described. - Viewer: the mx pattern is checked for the shape of a domain name, not against the full RFC 5321 Domain grammar; the media type, the DNS record and the certificates are not checked because nothing is fetched.
- Viewer: a file with no
versionandmodelines is not recognised and opens as plain text, so a badly broken policy shows no policy problems.
Unknown
- Reference: how a sender treats a byte order mark or non-UTF-8 text in a value: the ABNF allows UTF-8 only in extension values, and RFC 8461 says nothing more.