CD
Unknown User

Getting mta-sts worker to work

12 Replies
Tony Barrett
Tony Barrett2y ago
Did you ever find a solution to this? Currently having the same problem...
DarkDeviL
DarkDeviL2y ago
There was a similar thread on the Cloudflare Community, which can be found here: https://community.cloudflare.com/t/workers-for-mta-sts-not-getting-correct-url/537873. If the actual error says:
mta-sts.example.com is not defined in the mta-sts worker
Then you simply need to add a policy for mta-sts.example.com:
const stsPolicies = {
"mta-sts.yourdomain.tld":
`version: STSv1
mode: enforce
mx: *.mail.protection.outlook.com
max_age: 2419200`
}
const stsPolicies = {
"mta-sts.yourdomain.tld":
`version: STSv1
mode: enforce
mx: *.mail.protection.outlook.com
max_age: 2419200`
}
^ Alone changing "mta-sts.yourdomain.tld" to "mta-sts.example.com" at the line after const stsPolicies = { may be what you want. If you need to cover multiple ones at the same time, the code seems to me to indicate that you simply need to copy the "mta-sts.yourdomain.tld" key and it's value, and adjust them accordingly, for example like this:
const stsPolicies = {
"mta-sts.example.com":
`version: STSv1
mode: enforce
mx: example-com.mail.protection.outlook.com
max_age: 2419200`,
"mta-sts.example.net":
`version: STSv1
mode: enforce
mx: mx1.smtp.goog
mx: mx2.smtp.goog
mx: mx3.smtp.goog
mx: mx4.smtp.goog
max_age: 2419200`,
"mta-sts.example.org":
`version: STSv1
mode: enforce
mx: primary.mx.example.org
mx: secondary.mx.example.org
max_age: 2419200`
}
const stsPolicies = {
"mta-sts.example.com":
`version: STSv1
mode: enforce
mx: example-com.mail.protection.outlook.com
max_age: 2419200`,
"mta-sts.example.net":
`version: STSv1
mode: enforce
mx: mx1.smtp.goog
mx: mx2.smtp.goog
mx: mx3.smtp.goog
mx: mx4.smtp.goog
max_age: 2419200`,
"mta-sts.example.org":
`version: STSv1
mode: enforce
mx: primary.mx.example.org
mx: secondary.mx.example.org
max_age: 2419200`
}
In the above example: - example.com uses Microsoft Office 365 / Outlook. - example.net uses Google Workspace - example.org uses their own two mail servers. TL;DR: If it doesn't find a matching policy for the accessed domain under "stsPolicies", it will return the error code from above.
Tony Barrett
Tony Barrett2y ago
Thanks for your response, and I had a look at the thread in Cloudflare Community as well
Tony Barrett
Tony Barrett2y ago
That doesn't seem to be my problem though. I believe I have the correct domain inside stsPolicies:
No description
Tony Barrett
Tony Barrett2y ago
Can you see anything wrong in any of that @DarkDeviL?
DarkDeviL
DarkDeviL2y ago
That address seems to work fine from here?
DarkDeviL
DarkDeviL2y ago
No description
Tony Barrett
Tony Barrett2y ago
Huh Still not working for me, even with new browser, cleared cache, etc But awesome that it's working for you Maybe it just a DNS propagation lag (even though it's been several hours) I'll leave it until tomorrow and try again... hopefully it will be fine by then! Thanks for your help!
DarkDeviL
DarkDeviL2y ago
DNS shouldn't be the problem if you're seeing the "is not defined in the mta-sts worker" error text, as OP originally mentioned though. So that makes me curious, ... what exact error (or issue) do you see on your end? By reaching a couple of different Cloudflare PoPs within the European continent, such as Paris/France, Hamburg/Germany and London/UK, I do see consistent results, just like the one I was showing above.
Tony Barrett
Tony Barrett2y ago
Good question. I was getting that error originally in preview, until I realised that the preview mode was testing the .workers.dev URL… and that one WASN’T in stsPolicies. Now I’m testing the right domain and I’m getting a domain not found error. Sorry for the confusion… I’ve been changing multiple things over the past hour or so to try to get it to work and wasn’t explaining it all here, so thats my fault.
Tony Barrett
Tony Barrett2y ago
And I just tried it again on mobile, and got this:
No description
Tony Barrett
Tony Barrett2y ago
Looks like it was a combination of confusion on my part re what was being tested, and very slow DNS propagation… Thanks again for your help, and sorry for the hassle!

Did you find this page helpful?