From 51cca22d07028ec40da61d515095442ee8822d45 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 29 Jan 2019 06:07:43 -0800 Subject: [PATCH] Support EU domains for Mailgun API Summary: See . Mailgun has a couple of API domains depending on where your account is based. Test Plan: - Sent normal mail successfully with my non-EU account. - Waiting on user confirmation that this works in the EU. Reviewers: amckinley Reviewed By: amckinley Differential Revision: https://secure.phabricator.com/D20055 --- .../metamta/adapter/PhabricatorMailMailgunAdapter.php | 6 +++++- .../user/configuration/configuring_outbound_email.diviner | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php b/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php index 9eb478efc5..8223ee8102 100644 --- a/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailMailgunAdapter.php @@ -24,6 +24,7 @@ final class PhabricatorMailMailgunAdapter array( 'api-key' => 'string', 'domain' => 'string', + 'api-hostname' => 'string', )); } @@ -31,12 +32,14 @@ final class PhabricatorMailMailgunAdapter return array( 'api-key' => null, 'domain' => null, + 'api-hostname' => 'api.mailgun.net', ); } 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://api.mailgun.net/v2/%s/messages', + 'https://%s/v2/%s/messages', + $api_hostname, $domain); $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 6f5212680e..b77d761f80 100644 --- a/src/docs/user/configuration/configuring_outbound_email.diviner +++ b/src/docs/user/configuration/configuring_outbound_email.diviner @@ -227,6 +227,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 "api.mailgun.net". 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