MTA-STS Setup on Cloudflare: Workers, Pages & DNS TXT Guide
Deploy RFC 8461 MTA-STS on Cloudflare in under 5 minutes without a separate origin server: host https://mta-sts.<domain>/.well-known/mta-sts.txt via Cloudflare Pages or a 12-line Worker plus _mta-sts TXT.
Zero Telemetry · Strict CSP (connect-src 'none')
Domain Trust & Email-TLS Configuration
RFC 8461 · 8460 · 8659 · 9116
Input sanitization applied: stripped disallowed newlines, control characters, semicolons, or invalid hostname characters.
Type Name Flags Tag Value TTL
CAA @ 0 issue letsencrypt.org Auto
CAA @ 0 issue pki.goog Auto
CAA @ 0 issue digicert.com Auto
CAA @ 0 issue sectigo.com Auto
CAA @ 0 issuewild letsencrypt.org Auto
CAA @ 0 issuewild pki.goog Auto
CAA @ 0 issuewild digicert.com Auto
CAA @ 0 issuewild sectigo.com Auto
CAA @ 0 iodef mailto:[email protected] Auto
CAA-ISSUE-OK: 4 authorized CA(s) pinned via RFC 8659PASS
Only letsencrypt.org, pki.goog, digicert.com, sectigo.com may issue TLS certificates for example.com.
CAA-WILD-OK: Explicit issuewild records match authorized CAsPASS
Wildcard issuance (*.domain) is explicitly scoped to your selected CAs.
Verify Live DNS Records or Deploy All 9 ReadyCheck Fixes Together
In our N=140 B2B SaaS Readiness Benchmark, 95.2% (60/63) missed _mta-sts and 79.4% lacked valid RFC 9116 security.txt. Scan your live domain on ReadyCheck (https://audit.runglab.dev), order the tailored $49 9-File Domain Fix Pack, or automate via remote MCP Server dev.runglab/devtools.
Create a Cloudflare DNS Proxied (Orange Cloud) route for mta-sts.<domain>/* pointing to a Worker or Cloudflare Pages project.
Serve version: STSv1, mode: testing (initially), exact mx: patterns, and max_age: 604800 at /.well-known/mta-sts.txt with HTTP 200 and zero redirects.
Publish _mta-sts.<domain> TXT (v=STSv1; id=YYYYMMDDHHMMSSZ) and _smtp._tls.<domain> TXT (v=TLSRPTv1; rua=mailto:...).
Verify zero TLS failures via TLS-RPT for 7 days, switch mode to enforce, and bump id= in _mta-sts TXT.
In RungLab's N=140 B2B SaaS benchmark, 95.2% (60/63) of full-telemetry domains omit _mta-sts entirely — leaving inbound SMTP vulnerable to STARTTLS stripping.
RFC 8461 §3.3 strictly forbids following HTTP redirects when fetching mta-sts.txt. Cloudflare Bulk Redirects or Page Rules redirecting subdomains to www or apex will break MTA-STS silently.
Using Cloudflare Workers with a dummy Proxied AAAA record (100::) avoids spinning up any origin VM or bucket just to serve a 5-line text file.
Common Configuration Pitfalls to Avoid
Redirecting mta-sts.example.com to example.com or www.example.com — sending MTAs abort MTA-STS discovery on 301/302 responses.
Forgetting to update id= inside _mta-sts.<domain> TXT after changing mta-sts.txt, causing Gmail and Outlook to keep old cached MX rules until max_age expires.
Putting Cloudflare DNS proxy mode on mail MX hosts themselves (leave MX target A records DNS-Only gray cloud; only mta-sts.<domain> uses Orange Cloud HTTPS).
Exact RFC 8461 mta-sts.txt MX patterns for Google Workspace (both modern smtp.google.com and legacy 5-record aspmx.l.google.com setups), plus TLS-RPT validation and enforce rollout.
Configure RFC 8461 MTA-STS and RFC 8460 TLS-RPT for Microsoft 365 Exchange Online tenants using *.mail.protection.outlook.com, custom *.mx.microsoft endpoints, and safe testing-to-enforce rollout.
Publish RFC 8460 _smtp._tls.<domain> TXT records to receive daily compressed JSON reports from Gmail, Microsoft, and Yahoo detailing every successful STARTTLS/DANE/MTA-STS session and failure.
Build a compliant default._bimi.<domain> DNS TXT record and SVG Tiny 1.2 Portable/Secure (tiny-ps) logo, while avoiding the DMARC p=none and pct<100 traps that block Gmail and Apple Mail.
Compare Verified Mark Certificates (VMC) and Common Mark Certificates (CMC) for BIMI: trademark registration rules, DigiCert/Entrust issuance, Gmail blue checkmark vs logo-only display, and Apple Mail requirements.
Restrict which Certificate Authorities can issue TLS certificates for your domain with RFC 8659 CAA records: exact issue, issuewild, and iodef syntax for BIND and Cloudflare DNS.
Does Cloudflare Email Routing automatically enable MTA-STS?
No. Cloudflare Email Routing configures MX and SPF, but you must still publish https://mta-sts.<domain>/.well-known/mta-sts.txt (listing mx: *.mx.cloudflare.net) and the _mta-sts + _smtp._tls TXT records.
Why does RFC 8461 fail if mta-sts.<domain> returns a 301 redirect?
RFC 8461 §3.3 requires policy servers to avoid redirects because HTTP redirection to an untrusted host weakens certificate hostname validation. Always respond directly with 200 OK.
Can Cloudflare Pages serve /.well-known/mta-sts.txt without a Worker?
Yes — attach mta-sts.<domain> as a custom domain on a Cloudflare Pages project containing .well-known/mta-sts.txt and add a _headers rule setting Content-Type: text/plain; charset=utf-8.