MTA-STS (Mail Transfer Agent Strict Transport Security) is an email security standard specified in RFC 8461 that enables mail servers to enforce secure, encrypted TLS connections for inbound email traffic.
It prevents Man-in-the-Middle (MitM) and TLS-downgrade attacks by requiring sending servers to negotiate encrypted connections and verify the receiving server's TLS certificate before delivering email.
When an external mail transfer agent (MTA) attempts to send an email to your domain, it executes the following steps:
# **DNS TXT Record Check:** Queries DNS for ''_mta-sts.yourdomain.com'' to check if MTA-STS is enabled and if the policy version has changed. # **Policy Fetching:** Fetches the host's policy file over HTTPS from ''https://mta-sts.yourdomain.com/.well-known/mta-sts.txt''. # **TLS Certificate Verification:** Connects to the destination mail server via SMTP and verifies that its TLS certificate matches the hostnames listed in the MTA-STS policy file. # **Enforcement:** * If TLS validation succeeds: Delivers the email over an encrypted TLS connection. * If TLS validation fails or is tampered with (in ''enforce'' mode): Aborts delivery and drops the unencrypted connection.
The policy file must be hosted via HTTPS on a dedicated web endpoint at:
https://mta-sts.yourdomain.com/.well-known/mta-sts.txt
version: STSv1 mode: enforce mx: mail.telenegar.ir mx: *.telenegar.ir max_age: 604800
| Parameter | Description | Example / Values |
|---|---|---|
| version | Protocol version. Must be STSv1. | STSv1 |
| mode | Deployment mode for policy enforcement. | testing, enforce, or none |
| mx | Allowed mail server hostnames (wildcards like *.domain.com supported). | mx: mail.example.com |
| max_age | Time-to-live for policy caching in seconds (e.g., 604800 = 7 days). | 604800 |
To notify sending MTAs that your domain supports MTA-STS, create a TXT record at _mta-sts.yourdomain.com.
| Host / Name | Type | Text / Value | TTL |
|---|---|---|---|
_mta-sts | TXT | v=STSv1; id=2026080301; | 3600 |
To implement MTA-STS successfully, satisfy the following infrastructure requirements:
mta-sts.yourdomain.com.mta-sts.yourdomain.com must serve a valid, public SSL certificate (e.g., Let's Encrypt)./.well-known/mta-sts.txt returning HTTP header Content-Type: text/plain.
In enforce mode, if your mail server's SSL certificate expires or becomes invalid, external MTAs enforcing MTA-STS will bounce inbound email rather than falling back to plain-text port 25.
Ensure every hostname defined in your MX Records is explicitly covered by an mx: line in your mta-sts.txt policy file.
If you modify your MX configuration, remember to update the id= tag in your _mta-sts DNS record to force external servers to refresh their cached policy.
You can verify your MTA-STS record, MX configuration, and TLS status using Telenegar Tools or terminal commands:
_mta-sts TXT record with the Telenegar DNS Check Tool.bash dig +short TXT _mta-sts.example.com
cmd nslookup -type=TXT _mta-sts.example.com
bash curl -i https://mta-sts.example.com/.well-known/mta-sts.txt