Suped

What HTTP status code should an MTA-STS policy file return on success?

Mail Transfer Agent Strict Transport Security (MTA-STS) is a crucial security standard designed to protect email in transit. It ensures that when other mail servers send email to your domain, they do so over a secure, encrypted TLS connection, preventing eavesdropping and man-in-the-middle attacks. A key part of MTA-STS is the policy file, a simple text file you host on a web server. This file tells sending servers what your security requirements are. For this entire system to function correctly, your web server must respond with the right HTTP status code when a sending server requests your policy file. It's a small technical detail, but it makes all the difference.

Suped DMARC monitor
Free forever, no credit card required
Get started for free
Trusted by teams securing millions of inboxes
Company logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logoCompany logo

The required status code for an MTA-STS policy

The correct and required HTTP status code for a successfully retrieved MTA-STS policy file is 200 OK. This is not just a suggestion or a best practice; it's a mandatory requirement outlined in the official standard, RFC 8461. When a mail server requests your policy, a 200 OK response indicates that the request was successful and the policy is contained in the response body.

developer.mozilla.org logo
MDN Web Docs says:
Visit website
Successful responses · 200 OK. The request succeeded. · 201 Created. The request succeeded, and a new resource was created as a result. · 202 ...

Why a 200 OK is necessary

To understand why this specific code is required, think of the process. A remote mail server acts as a client. It makes an HTTPS GET request to a very specific URL: https://mta-sts.yourdomain.com/.well-known/mta-sts.txt. Your web server, which hosts this file, must respond to this request. A 200 OK is the universal signal for "I have found what you asked for, and here it is." Any other response code signals a problem or a different outcome, which will cause the sending server to ignore your policy.

github.com logo
GitHub says:
Visit website
The run.ps1 file is responsible for returning the MTA-STS policy. The following code will return a MTA-STS policy in enforce mode for the domain.

Using an incorrect status code can lead to several problems:

  • Policy is ignored: If your server returns a 404 Not Found, 500 Server Error, or even a 301 Moved Permanently redirect, the sending MTA will treat your policy as unavailable. It will not follow redirects.
  • Caching problems: MTA-STS policies are cached by senders for a duration specified within the policy itself. An improper status code can disrupt this caching behavior, causing inconsistent policy enforcement.
  • Security is compromised: If your policy cannot be fetched, sending servers may fall back to sending email over unencrypted connections, defeating the entire purpose of MTA-STS and leaving your communications vulnerable.

The standards bodies that create internet protocols, like the IETF, are strict about these details to ensure that systems built by different companies all over the world can communicate reliably. In short, to properly implement MTA-STS, you must ensure your web server configuration returns a 200 OK for your policy file. It's a simple, non-negotiable step for securing your email.

Start improving your email deliverability today

Get started