What MTA-STS does

Mail Transfer Agent Strict Transport Security (MTA-STS) is a way for a domain that receives email to publish its expectations for incoming mail delivery. A supporting sending server can use the policy to check that it is connecting to an approved mail exchanger (MX) over TLS with a valid certificate. This helps protect mail delivery when a network attacker tries to interfere with DNS answers or the connection to a mail server.

An MTA-STS setup has three connected parts: a TXT record that signals the policy, a policy file served over HTTPS, and MX hostnames that agree with the policy. It does not replace MX records or make every sender use TLS. Its protection depends on the sending server supporting MTA-STS and having a usable policy.

Publish the signaling DNS record

For a domain such as example.com, add a TXT record at _mta-sts.example.com. Its value can look like v=STSv1; id=policy1. The v field identifies the MTA-STS version. The id field is an identifier for the current policy; change it when you change the policy file so supporting senders know to fetch the updated version.

This TXT record is a signal, not the policy itself. It does not list MX hosts or specify whether the domain is enforcing TLS. Those settings belong in the HTTPS file. When checking the record, make sure the name is _mta-sts.example.com, rather than mta-sts.example.com: the underscore-prefixed DNS name and the HTTPS hostname serve different purposes.

Host the HTTPS policy file

For example.com, the policy file belongs at https://mta-sts.example.com/.well-known/mta-sts.txt. The web server at mta-sts.example.com needs a valid HTTPS certificate for that hostname, and the file must be publicly reachable without a login. This host can be separate from the website and from the servers that receive mail.

A simple policy file consists of plain-text lines such as v: STSv1, mode: testing, mx: mx1.example.com, and max_age: 86400, each on its own line. The mx line names a permitted receiving mail server; add another mx line for each additional permitted hostname. max_age is the time, in seconds, that a sender may cache the policy. The exact value should fit how confidently you can keep the policy and its hosts available.

The mode controls how supporting senders use the policy. In testing mode, they do not refuse delivery solely because a connection fails the MTA-STS checks. In enforce mode, supporting senders should not deliver to an MX host that fails those checks while the policy applies. The mode none is used to indicate that a previously published policy should no longer be enforced; simply removing the file may leave cached policies in use until they expire.

Make the MX records and certificates agree

First, inspect the domain’s MX records. If example.com publishes MX hosts mx1.example.com and mx2.example.com, list both hostnames in the policy if both should receive mail. An MX priority number does not make a hostname exempt: a sender may try a backup MX when the preferred one is unavailable. Avoid listing a hostname merely because it resembles an MX host; the policy should reflect the actual receiving service.

Next, check TLS on every listed MX host. A receiving server must present a certificate valid for the MX hostname a sender connects to. A certificate for example.com does not automatically cover mx1.example.com. If a mail provider operates your MX hosts, confirm its documented MTA-STS requirements before writing the policy. An enforcement policy that omits a working MX host or names a host with an invalid certificate can prevent supporting senders from delivering mail.

Check the setup before enforcing it

Verify each part independently: look up the _mta-sts TXT record, retrieve the policy at the required HTTPS path, compare every mx line with the published MX records, and check TLS certificates on the receiving hosts. DNS and policy changes may take time to reach senders, and senders may retain a cached policy for its max_age. Plan changes with that caching in mind, particularly when replacing or removing MX hosts.

Testing mode is a useful first step, but it does not automatically provide a report of failures. To receive reports from participating senders, configure TLS reporting separately. Once the policy, MX records, and certificates agree, you can consider changing the mode to enforce and updating the TXT record’s id. Recheck the same pieces whenever your mail provider or receiving-server hostnames change.

Back to category ↗