# MTA-STS and TLS reports Require other mail servers to deliver to you over encrypted connections (**TLS**), and learn when they cannot. Both are off by default, per domain. For domain admins. | Feature | What it does | | --- | --- | | **TLS reports** (TLS-RPT, RFC 8460) | Senders report daily how many TLS connections worked or failed | | **MTA-STS** (RFC 8461) | A published policy: deliver only over TLS, only to listed mail servers | ## Prerequisites - For TLS reports: [DMARC reports](dmarc-reports.md) turned on. - For MTA-STS: valid certificates on your mail servers, and the ability to add `mta-sts.`. - Database migrations applied. ## Turn on TLS reports 1. Open **Admin → Email → Deliverability → TLS reports**. 2. Select **Turn on TLS reports**. This adds `mailto:mailflare-reports@` to the TXT record `_smtp._tls.` at once. | Current state | Change | | --- | --- | | No record | Creates `v=TLSRPTv1; rua=mailto:
` | | Other destinations | Adds the address; keeps the rest | | Several records | Refused. Remove the extras. | | Zone not managed | Shows the value to publish | **Turn off** removes only this address (or the record, if nothing else is in it). Turn TLS reports off before DMARC reports. The tab shows sessions per day, failure reasons, totals by policy, mail server and reporter, and recent reports. ## Publish MTA-STS 1. [Attach the policy host](#attach-the-policy-host). 2. On the **MTA-STS** tab, select **Publish in testing mode**. 3. Select **Check the host**. 4. Watch TLS reports for a while. 5. Switch to **enforce** and confirm that every MX host has a valid certificate for its name. | Mode | Senders | | --- | --- | | testing | Report problems, still deliver | | enforce | Refuse hosts that fail; mail can be delayed or bounce | | none (while turning off) | Stop enforcing | Publishing reads your MX records (at most 20 host names). It is refused if there are none or one is not a plain host name. Hosts other than Cloudflare or SES get a warning, because Mailflare cannot check their certificates. Mailflare writes `_mta-sts.` as `v=STSv1; id=`. It never overwrites a record it did not create. For unmanaged zones, publish the shown value yourself. The cache time (`max_age`) is 1 day to 1 year, default 1 week, and can change in either mode. ## Attach the policy host Senders fetch `https://mta-sts./.well-known/mta-sts.txt`. **Mailflare does not create this host.** Add it once per domain. **Cloudflare Workers:** Workers & Pages → your Worker → **Settings → Domains & Routes → Add → Custom domain** → `mta-sts.`. The certificate can take a few minutes. **Docker:** point `mta-sts.` at your server and proxy it with a certificate. The proxy must keep the `Host` header. Caddy example: ```text mta-sts.example.com { reverse_proxy mailflare:3000 } ``` **Check the host** fetches the policy from your browser and compares it. Redirects count as failure. The result is information only. ## Change mail servers In **enforce** mode, Mailflare refuses (error 409) anything that moves MX: provider setup or removal, switching provider, and the MX/SPF/DKIM replace buttons. 1. Switch to **testing**. 2. Make the change. The policy is republished with the new MX list. 3. Watch TLS reports. 4. Switch back to **enforce**. Enforce is also refused if live MX records differ from the list you tested. The tab warns about differences. ## Turn off MTA-STS Select **Turn off MTA-STS**. A `mode: none` policy is served for the longest cache time used, so senders forget the old one. The daily job (02:00 UTC) then deletes `_mta-sts`; the host returns 404. Failed deletes are retried daily. For unmanaged zones, delete the TXT record yourself after the date shown. Publishing again cancels removal. ## Delete a domain You cannot delete a domain while its policy is published, including the removal period. Deleting also removes the TLS report address, or waits until you turn TLS reports off if it cannot. If Cloudflare no longer serves the zone to your token (404 or 403), it counts as unmanaged: turn the features off in the app and remove the records yourself. ### Force delete Use this only when the policy cannot be removed normally. > **Warning:** Senders may keep the cached policy until its expiry. In enforce mode they refuse mail to unlisted MX hosts until then. The domain page offers it after you type the domain name. Over the API, send this body to `DELETE /api/domains/[id]` or `/api/v1/domains/[id]` (a wrong `confirm` returns 400): ```json { "force": true, "confirm": "example.com" } ``` Removal is [scheduled](api.md#removing-a-domain) as usual. The audit entry `domain.force_delete` lists `leftovers` (DNS records to remove by hand, always including the `mta-sts` host) and `cachedUntil`. ## How reports are trusted TLS reports use the same address, processing, trust rules and daily limits as [DMARC reports](dmarc-reports.md#which-reports-are-trusted). Only verified reports add totals. Row budgets are shared. TLS reports do not reset the DMARC **No reports** alert. | Item | Limit | | --- | --- | | Size | 5 MiB email, 3 MiB compressed, 8 MiB and 1000x expanded; gzip or JSON (no zip) | | JSON depth | 8 levels | | Policies per report | 1,000 | | Failure details per policy | 100 | | Session counts | Whole numbers 0 to 10,000,000, else rejected | | Dates | RFC 3339; 180 days back to 1 day ahead; 7 days long | | Text | Trimmed like DMARC fields; unknown result types show as `other` | | Rows saved per report | 500 busiest | Policies for other domains are ignored. No URL is fetched. Limits are in `src/lib/deliverability/report-parse.ts`. ## Technical reference - **Policy host guard** (`guardMtaStsHost`): on `mta-sts.*` hosts, only `GET` and `HEAD` of the policy path work (else 404 or 405). Other hosts get 404 for the policy. - **Response:** `text/plain; charset=utf-8`, `Cache-Control: public, max-age=300`, `Access-Control-Allow-Origin: *`, `nosniff`, no redirects or cookies. - **Policy id:** changes when mode, MX list or cache time changes. DNS is written before the policy is stored. - **Data:** columns on `domain_deliverability`, `kind` on `deliverability_reports`, table `tls_daily_stats` (SQLite migration `0101`, PostgreSQL/MySQL `0025`). Kept 180 days. Backups restore to unmigrated databases (new columns dropped). - **Before migration:** the inbound queue retries reports that encounter a missing table or column. The policy host returns 404 and the routes return 409 `MIGRATION_REQUIRED`. ## Known limitations - No alert for TLS failures. - The host check is reported by your browser; the server does not verify it. - Large reports can exceed the Workers Free CPU limit (see [DMARC limitations](dmarc-reports.md#known-limitations)). - If two accounts own the same host name, the first published policy is served. - Unmanaged zones: you edit DNS yourself. ## Troubleshooting | Problem | Cause | Fix | | --- | --- | --- | | Cannot turn on TLS reports | DMARC reports off | Turn them on | | Host check fails | Host not attached or redirects | Attach it without redirects | | 409 on MX change | Enforce mode | Switch to testing | | Publishing refused | Foreign `_mta-sts` record or bad MX | Fix DNS | | Cannot delete domain | Policy still published | Turn off and wait, or force delete |