Mailgun EU zone not working


Observed Behavior:
Mailgun added a new EU zone to their service. Sending mails using accounts on this zone requires a different base url. Currently the base url ( is hardcoded in Phabricator
(/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php). For the EU zone should be used.

Expected Behavior:
The base url should be configurable with a default of

Phabricator Version:

9cf0d58e5da0d3673481456e38257ca41cc3d987 (Fri, Jan 25) (branched from e6ca2b998fd4ba1d197322228f408b2461314659 on origin)


97ddb9d5a1be282d6002a875a759266bb97b653f (Dec 28 2018) (branched from 25c2381959ac94d9249ae4023c5f9ea36436b81c on origin)


8a9f4b1f806e9eff0fbf5b32cfc29842c0db3f49 (Sat, Jan 19) (branched from 92413d0303ab2f86eb397db0441b024de4099975 on origin)

Reproduction Steps:

  1. Setup a new Mailgun account in their EU zone
  2. Configure Phabricator to send mail using this account
  3. Send a test mail - this will fail because credentials are invalid on the default Mailgun domain

If I give you a proposed patch for this, can you test it so I don’t have to set up an EU zone account? The Phabricator change is probably quite simple but setting up an account might be a bit of work.

commit ac363ba52ca6d5723f9d8f654b5ab2fde922f1e5
Author: epriestley <>
Date:   Tue Jan 29 06:07:43 2019 -0800


diff --git a/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php b/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php
index 9eb478efc..8223ee810 100644
--- a/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php
+++ b/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php
@@ -24,6 +24,7 @@ final class PhabricatorMailMailgunAdapter
         'api-key' => 'string',
         'domain' => 'string',
+        'api-hostname' => 'string',
@@ -31,12 +32,14 @@ final class PhabricatorMailMailgunAdapter
     return array(
       'api-key' => null,
       'domain' => null,
+      'api-hostname' => '',
   public function sendMessage(PhabricatorMailExternalMessage $message) {
     $api_key = $this->getOption('api-key');
     $domain = $this->getOption('domain');
+    $api_hostname = $this->getOption('api-hostname');
     $params = array();
     $subject = $message->getSubject();
@@ -92,7 +95,8 @@ final class PhabricatorMailMailgunAdapter
     $mailgun_uri = urisprintf(
-      '',
+      'https://%s/v2/%s/messages',
+      $api_hostname,
     $future = id(new HTTPSFuture($mailgun_uri, $params))
diff --git a/src/docs/user/configuration/configuring_outbound_email.diviner b/src/docs/user/configuration/configuring_outbound_email.diviner
index 4d18ba0eb..7b04d8a4c 100644
--- a/src/docs/user/configuration/configuring_outbound_email.diviner
+++ b/src/docs/user/configuration/configuring_outbound_email.diviner
@@ -214,6 +214,9 @@ To use this mailer, set `type` to `mailgun`, then configure these `options`:
   - `api-key`: Required string. Your Mailgun API key.
   - `domain`: Required string. Your Mailgun domain.
+  - `api-hostname`: Optional string. Defaults to "". If your
+    account is in another region (like the EU), you may need to specify a
+    different hostname. Consult the Mailgun documentation.
 Mailer: Amazon SES
1 Like

@epriestley I have had the same issue and tested your fix. It works. Thanks.

One side note for testing mailgun - it asks you US or EU each time you set up a domain, thus if you need to test in future you can just set up a subdomain to test for each region. Hopefully this helps with simplifying the testing.:

And thanks again for your work and amazing product!

closed #5