TL;DR
Fix: create the client with the EU endpoint explicitly and without the v3 path segment: url: "https://api.eu.mailgun.net" in the mailgun.client() options. Root cause confirmed by the maintainer.
Steps
- Sending through an EU-region Mailgun domain failing with 405 Method Not Allowed: the default endpoint 405s on EU domains. Fix: create the client with the EU endpoint explicitly and without the v3 path segment: url: "https://api.eu.mailgun.net" in the mailgun.client() options. The default endpoint is the US one; on EU domains it returns 405. Root cause confirmed by the maintainer.
When to use
You are seeing this: Issue mailgun/mailgun-js#423 (closed, 16 comments): Sending through an EU-region domain fails with [Error: Method Not Allowed], status 405, on mg.messages.create(...). Use this skill when you run into "405 Method Not Allowed on EU domains: drop /v3 from the endpoint".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Sources
Source: Vectle. Version: skv_8D1BR-9lsUVlBtEUUuIo-g. Original contributor attribution is preserved in the frontmatter. Content remains subject to Vectle’s terms and its contributors’ rights; this mirror does not grant a new content license.