diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5b9e818765..a0a4c68b43 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3405,10 +3405,8 @@ phutil_register_library_map(array( 'PhabricatorMailReceiverTestCase' => 'applications/metamta/receiver/__tests__/PhabricatorMailReceiverTestCase.php', 'PhabricatorMailReplyHandler' => 'applications/metamta/replyhandler/PhabricatorMailReplyHandler.php', 'PhabricatorMailRoutingRule' => 'applications/metamta/constants/PhabricatorMailRoutingRule.php', - 'PhabricatorMailSetupCheck' => 'applications/config/check/PhabricatorMailSetupCheck.php', 'PhabricatorMailStamp' => 'applications/metamta/stamp/PhabricatorMailStamp.php', 'PhabricatorMailTarget' => 'applications/metamta/replyhandler/PhabricatorMailTarget.php', - 'PhabricatorMailgunConfigOptions' => 'applications/config/option/PhabricatorMailgunConfigOptions.php', 'PhabricatorMainMenuBarExtension' => 'view/page/menu/PhabricatorMainMenuBarExtension.php', 'PhabricatorMainMenuSearchView' => 'view/page/menu/PhabricatorMainMenuSearchView.php', 'PhabricatorMainMenuView' => 'view/page/menu/PhabricatorMainMenuView.php', @@ -3657,7 +3655,6 @@ phutil_register_library_map(array( 'PhabricatorPHIDsSearchField' => 'applications/search/field/PhabricatorPHIDsSearchField.php', 'PhabricatorPHPASTApplication' => 'applications/phpast/application/PhabricatorPHPASTApplication.php', 'PhabricatorPHPConfigSetupCheck' => 'applications/config/check/PhabricatorPHPConfigSetupCheck.php', - 'PhabricatorPHPMailerConfigOptions' => 'applications/config/option/PhabricatorPHPMailerConfigOptions.php', 'PhabricatorPHPPreflightSetupCheck' => 'applications/config/check/PhabricatorPHPPreflightSetupCheck.php', 'PhabricatorPackagesApplication' => 'applications/packages/application/PhabricatorPackagesApplication.php', 'PhabricatorPackagesController' => 'applications/packages/controller/PhabricatorPackagesController.php', @@ -4312,7 +4309,6 @@ phutil_register_library_map(array( 'PhabricatorSecuritySetupCheck' => 'applications/config/check/PhabricatorSecuritySetupCheck.php', 'PhabricatorSelectEditField' => 'applications/transactions/editfield/PhabricatorSelectEditField.php', 'PhabricatorSelectSetting' => 'applications/settings/setting/PhabricatorSelectSetting.php', - 'PhabricatorSendGridConfigOptions' => 'applications/config/option/PhabricatorSendGridConfigOptions.php', 'PhabricatorSessionsSettingsPanel' => 'applications/settings/panel/PhabricatorSessionsSettingsPanel.php', 'PhabricatorSetConfigType' => 'applications/config/type/PhabricatorSetConfigType.php', 'PhabricatorSetting' => 'applications/settings/setting/PhabricatorSetting.php', @@ -9214,10 +9210,8 @@ phutil_register_library_map(array( 'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase', 'PhabricatorMailReplyHandler' => 'Phobject', 'PhabricatorMailRoutingRule' => 'Phobject', - 'PhabricatorMailSetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorMailStamp' => 'Phobject', 'PhabricatorMailTarget' => 'Phobject', - 'PhabricatorMailgunConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorMainMenuBarExtension' => 'Phobject', 'PhabricatorMainMenuSearchView' => 'AphrontView', 'PhabricatorMainMenuView' => 'AphrontView', @@ -9509,7 +9503,6 @@ phutil_register_library_map(array( 'PhabricatorPHIDsSearchField' => 'PhabricatorSearchField', 'PhabricatorPHPASTApplication' => 'PhabricatorApplication', 'PhabricatorPHPConfigSetupCheck' => 'PhabricatorSetupCheck', - 'PhabricatorPHPMailerConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorPHPPreflightSetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorPackagesApplication' => 'PhabricatorApplication', 'PhabricatorPackagesController' => 'PhabricatorController', @@ -10331,7 +10324,6 @@ phutil_register_library_map(array( 'PhabricatorSecuritySetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorSelectEditField' => 'PhabricatorEditField', 'PhabricatorSelectSetting' => 'PhabricatorSetting', - 'PhabricatorSendGridConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorSessionsSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorSetConfigType' => 'PhabricatorTextConfigType', 'PhabricatorSetting' => 'Phobject', diff --git a/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php b/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php index 4bf51602ba..286de7f63b 100644 --- a/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php +++ b/src/applications/config/check/PhabricatorExtraConfigSetupCheck.php @@ -193,12 +193,15 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck { 'in global settings.'); $dashboard_reason = pht( - 'This option has been removed, you can use Dashboards to provide '. - 'homepage customization. See T11533 for more details.'); + 'This option has been removed, you can use Dashboards to provide '. + 'homepage customization. See T11533 for more details.'); $elastic_reason = pht( - 'Elasticsearch is now configured with "%s".', - 'cluster.search'); + 'Elasticsearch is now configured with "%s".', + 'cluster.search'); + + $mailers_reason = pht( + 'Inbound and outbound mail is now configured with "cluster.mailers".'); $ancient_config += array( 'phid.external-loaders' => @@ -354,6 +357,21 @@ final class PhabricatorExtraConfigSetupCheck extends PhabricatorSetupCheck { 'search.elastic.host' => $elastic_reason, 'search.elastic.namespace' => $elastic_reason, + 'metamta.mail-adapter' => $mailers_reason, + 'amazon-ses.access-key' => $mailers_reason, + 'amazon-ses.secret-key' => $mailers_reason, + 'amazon-ses.endpoint' => $mailers_reason, + 'mailgun.domain' => $mailers_reason, + 'mailgun.api-key' => $mailers_reason, + 'phpmailer.mailer' => $mailers_reason, + 'phpmailer.smtp-host' => $mailers_reason, + 'phpmailer.smtp-port' => $mailers_reason, + 'phpmailer.smtp-protocol' => $mailers_reason, + 'phpmailer.smtp-user' => $mailers_reason, + 'phpmailer.smtp-password' => $mailers_reason, + 'phpmailer.smtp-encoding' => $mailers_reason, + 'sendgrid.api-user' => $mailers_reason, + 'sendgrid.api-key' => $mailers_reason, ); return $ancient_config; diff --git a/src/applications/config/check/PhabricatorMailSetupCheck.php b/src/applications/config/check/PhabricatorMailSetupCheck.php deleted file mode 100644 index b3b6143ad0..0000000000 --- a/src/applications/config/check/PhabricatorMailSetupCheck.php +++ /dev/null @@ -1,104 +0,0 @@ -newIssue('config.metamta.mail-adapter') - ->setShortName(pht('Missing Sendmail')) - ->setName(pht('No Sendmail Binary Found')) - ->setMessage($message) - ->addRelatedPhabricatorConfig('metamta.mail-adapter'); - } - break; - case 'PhabricatorMailImplementationAmazonSESAdapter': - if (PhabricatorEnv::getEnvConfig('metamta.can-send-as-user')) { - $message = pht( - 'Amazon SES does not support sending email as users. Disable '. - 'send as user, or choose a different mail adapter.'); - - $this->newIssue('config.can-send-as-user') - ->setName(pht("SES Can't Send As User")) - ->setMessage($message) - ->addRelatedPhabricatorConfig('metamta.mail-adapter') - ->addPhabricatorConfig('metamta.can-send-as-user'); - } - - if (!PhabricatorEnv::getEnvConfig('amazon-ses.access-key')) { - $message = pht( - 'Amazon SES is selected as the mail adapter, but no SES access '. - 'key is configured. Provide an SES access key, or choose a '. - 'different mail adapter.'); - - $this->newIssue('config.amazon-ses.access-key') - ->setName(pht('Amazon SES Access Key Not Set')) - ->setMessage($message) - ->addRelatedPhabricatorConfig('metamta.mail-adapter') - ->addPhabricatorConfig('amazon-ses.access-key'); - } - - if (!PhabricatorEnv::getEnvConfig('amazon-ses.secret-key')) { - $message = pht( - 'Amazon SES is selected as the mail adapter, but no SES secret '. - 'key is configured. Provide an SES secret key, or choose a '. - 'different mail adapter.'); - - $this->newIssue('config.amazon-ses.secret-key') - ->setName(pht('Amazon SES Secret Key Not Set')) - ->setMessage($message) - ->addRelatedPhabricatorConfig('metamta.mail-adapter') - ->addPhabricatorConfig('amazon-ses.secret-key'); - } - - if (!PhabricatorEnv::getEnvConfig('amazon-ses.endpoint')) { - $message = pht( - 'Amazon SES is selected as the mail adapter, but no SES endpoint '. - 'is configured. Provide an SES endpoint or choose a different '. - 'mail adapter.'); - - $this->newIssue('config.amazon-ses.endpoint') - ->setName(pht('Amazon SES Endpoint Not Set')) - ->setMessage($message) - ->addRelatedPhabricatorConfig('metamta.mail-adapter') - ->addPhabricatorConfig('amazon-ses.endpoint'); - } - - $address_key = 'metamta.default-address'; - $options = PhabricatorApplicationConfigOptions::loadAllOptions(); - $default = $options[$address_key]->getDefault(); - $value = PhabricatorEnv::getEnvConfig($address_key); - if ($default === $value) { - $message = pht( - 'Amazon SES requires verification of the "From" address, but '. - 'you have not configured a "From" address. Configure and verify '. - 'a "From" address, or choose a different mail adapter.'); - - $this->newIssue('config.metamta.default-address') - ->setName(pht('No SES From Address Configured')) - ->setMessage($message) - ->addRelatedPhabricatorConfig('metamta.mail-adapter') - ->addPhabricatorConfig('metamta.default-address'); - } - break; - } - - } -} diff --git a/src/applications/config/option/PhabricatorAWSConfigOptions.php b/src/applications/config/option/PhabricatorAWSConfigOptions.php index 6647930859..5f2246fdaa 100644 --- a/src/applications/config/option/PhabricatorAWSConfigOptions.php +++ b/src/applications/config/option/PhabricatorAWSConfigOptions.php @@ -21,24 +21,6 @@ final class PhabricatorAWSConfigOptions public function getOptions() { return array( - $this->newOption('amazon-ses.access-key', 'string', null) - ->setLocked(true) - ->setDescription(pht('Access key for Amazon SES.')), - $this->newOption('amazon-ses.secret-key', 'string', null) - ->setHidden(true) - ->setDescription(pht('Secret key for Amazon SES.')), - $this->newOption('amazon-ses.endpoint', 'string', null) - ->setLocked(true) - ->setDescription( - pht( - 'SES endpoint domain name. You can find a list of available '. - 'regions and endpoints in the AWS documentation.')) - ->addExample( - 'email.us-east-1.amazonaws.com', - pht('US East (N. Virginia, Older default endpoint)')) - ->addExample( - 'email.us-west-2.amazonaws.com', - pht('US West (Oregon)')), $this->newOption('amazon-s3.access-key', 'string', null) ->setLocked(true) ->setDescription(pht('Access key for Amazon S3.')), diff --git a/src/applications/config/option/PhabricatorMailgunConfigOptions.php b/src/applications/config/option/PhabricatorMailgunConfigOptions.php deleted file mode 100644 index cc4e71fb59..0000000000 --- a/src/applications/config/option/PhabricatorMailgunConfigOptions.php +++ /dev/null @@ -1,38 +0,0 @@ -newOption('mailgun.domain', 'string', null) - ->setLocked(true) - ->setDescription( - pht( - 'Mailgun domain name. See %s.', - 'https://mailgun.com/cp/domains')) - ->addExample('mycompany.com', pht('Use specific domain')), - $this->newOption('mailgun.api-key', 'string', null) - ->setHidden(true) - ->setDescription(pht('Mailgun API key.')), - ); - - } - -} diff --git a/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php b/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php index ad8a62d184..0ad8c5c0d7 100644 --- a/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php +++ b/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php @@ -208,13 +208,6 @@ EODOC 'string', 'phabricator.example.com') ->setDescription(pht('Domain used to generate Message-IDs.')), - $this->newOption( - 'metamta.mail-adapter', - 'class', - 'PhabricatorMailImplementationPHPMailerLiteAdapter') - ->setBaseClass('PhabricatorMailImplementationAdapter') - ->setSummary(pht('Control how mail is sent.')) - ->setDescription($adapter_description), $this->newOption( 'metamta.one-mail-per-recipient', 'bool', diff --git a/src/applications/config/option/PhabricatorPHPMailerConfigOptions.php b/src/applications/config/option/PhabricatorPHPMailerConfigOptions.php deleted file mode 100644 index 2c0021341f..0000000000 --- a/src/applications/config/option/PhabricatorPHPMailerConfigOptions.php +++ /dev/null @@ -1,72 +0,0 @@ -newOption('phpmailer.mailer', 'string', 'smtp') - ->setLocked(true) - ->setSummary(pht('Configure mailer used by PHPMailer.')) - ->setDescription( - pht( - "If you're using PHPMailer to send email, provide the mailer and ". - "options here. PHPMailer is much more enormous than ". - "PHPMailerLite, and provides more mailers and greater enormity. ". - "You need it when you want to use SMTP instead of sendmail as the ". - "mailer.")), - $this->newOption('phpmailer.smtp-host', 'string', null) - ->setLocked(true) - ->setDescription(pht('Host for SMTP.')), - $this->newOption('phpmailer.smtp-port', 'int', 25) - ->setLocked(true) - ->setDescription(pht('Port for SMTP.')), - // TODO: Implement "enum"? Valid values are empty, 'tls', or 'ssl'. - $this->newOption('phpmailer.smtp-protocol', 'string', null) - ->setLocked(true) - ->setSummary(pht('Configure TLS or SSL for SMTP.')) - ->setDescription( - pht( - "Using PHPMailer with SMTP, you can set this to one of '%s' or ". - "'%s' to use TLS or SSL, respectively. Leave it blank for ". - "vanilla SMTP. If you're sending via Gmail, set it to '%s'.", - 'tls', - 'ssl', - 'ssl')), - $this->newOption('phpmailer.smtp-user', 'string', null) - ->setLocked(true) - ->setDescription(pht('Username for SMTP.')), - $this->newOption('phpmailer.smtp-password', 'string', null) - ->setHidden(true) - ->setDescription(pht('Password for SMTP.')), - $this->newOption('phpmailer.smtp-encoding', 'string', 'base64') - ->setSummary(pht('Configure how mail is encoded.')) - ->setDescription( - pht( - "Mail is normally encoded in `8bit`, which works correctly with ". - "most MTAs. However, some MTAs do not work well with this ". - "encoding. If you're having trouble with mail being mangled or ". - "arriving with too many or too few newlines, you may try ". - "adjusting this setting.\n\n". - "Supported values are `8bit`, `quoted-printable`, ". - "`7bit`, `binary` and `base64`.")), - ); - } - -} diff --git a/src/applications/config/option/PhabricatorSendGridConfigOptions.php b/src/applications/config/option/PhabricatorSendGridConfigOptions.php deleted file mode 100644 index 0baa7390af..0000000000 --- a/src/applications/config/option/PhabricatorSendGridConfigOptions.php +++ /dev/null @@ -1,33 +0,0 @@ -newOption('sendgrid.api-user', 'string', null) - ->setLocked(true) - ->setDescription(pht('SendGrid API username.')), - $this->newOption('sendgrid.api-key', 'string', null) - ->setHidden(true) - ->setDescription(pht('SendGrid API key.')), - ); - } - -} diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationAdapter.php index 8a6b2d2275..a8dba2335b 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationAdapter.php @@ -109,7 +109,6 @@ abstract class PhabricatorMailImplementationAdapter extends Phobject { abstract protected function validateOptions(array $options); abstract public function newDefaultOptions(); - abstract public function newLegacyOptions(); public function prepareForSend() { return; diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationAmazonSESAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationAmazonSESAdapter.php index a26b074df9..f847488019 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationAmazonSESAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationAmazonSESAdapter.php @@ -39,15 +39,6 @@ final class PhabricatorMailImplementationAmazonSESAdapter ); } - public function newLegacyOptions() { - return array( - 'access-key' => PhabricatorEnv::getEnvConfig('amazon-ses.access-key'), - 'secret-key' => PhabricatorEnv::getEnvConfig('amazon-ses.secret-key'), - 'endpoint' => PhabricatorEnv::getEnvConfig('amazon-ses.endpoint'), - 'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'), - ); - } - /** * @phutil-external-symbol class SimpleEmailService */ diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php index 349dae2d27..b917a93df2 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationMailgunAdapter.php @@ -89,13 +89,6 @@ final class PhabricatorMailImplementationMailgunAdapter ); } - public function newLegacyOptions() { - return array( - 'api-key' => PhabricatorEnv::getEnvConfig('mailgun.api-key'), - 'domain' => PhabricatorEnv::getEnvConfig('mailgun.domain'), - ); - } - public function send() { $key = $this->getOption('api-key'); $domain = $this->getOption('domain'); diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerAdapter.php index ae134a29b8..fbc8c09cd9 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerAdapter.php @@ -33,18 +33,6 @@ final class PhabricatorMailImplementationPHPMailerAdapter ); } - public function newLegacyOptions() { - return array( - 'host' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-host'), - 'port' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-port'), - 'user' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-user'), - 'password' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-password'), - 'protocol' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-protocol'), - 'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'), - 'mailer' => PhabricatorEnv::getEnvConfig('phpmailer.mailer'), - ); - } - /** * @phutil-external-symbol class PHPMailer */ diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php index 1f21a993c9..427248e39b 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationPHPMailerLiteAdapter.php @@ -24,12 +24,6 @@ class PhabricatorMailImplementationPHPMailerLiteAdapter ); } - public function newLegacyOptions() { - return array( - 'encoding' => PhabricatorEnv::getEnvConfig('phpmailer.smtp-encoding'), - ); - } - /** * @phutil-external-symbol class PHPMailerLite */ diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationPostmarkAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationPostmarkAdapter.php index 5792ba08f8..2b80905604 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationPostmarkAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationPostmarkAdapter.php @@ -94,10 +94,6 @@ final class PhabricatorMailImplementationPostmarkAdapter ); } - public function newLegacyOptions() { - return array(); - } - public function send() { $access_token = $this->getOption('access-token'); diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php index be2a837053..eb451adfc9 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationSendGridAdapter.php @@ -26,13 +26,6 @@ final class PhabricatorMailImplementationSendGridAdapter ); } - public function newLegacyOptions() { - return array( - 'api-user' => PhabricatorEnv::getEnvConfig('sendgrid.api-user'), - 'api-key' => PhabricatorEnv::getEnvConfig('sendgrid.api-key'), - ); - } - public function setFrom($email, $name = '') { $this->params['from'] = $email; $this->params['from-name'] = $name; @@ -97,18 +90,9 @@ final class PhabricatorMailImplementationSendGridAdapter } public function send() { - $user = $this->getOption('api-user'); $key = $this->getOption('api-key'); - if (!$user || !$key) { - throw new Exception( - pht( - "Configure '%s' and '%s' to use SendGrid for mail delivery.", - 'sendgrid.api-user', - 'sendgrid.api-key')); - } - $params = array(); $ii = 0; diff --git a/src/applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php b/src/applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php index 80807398f1..61b9bdfb4f 100644 --- a/src/applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php +++ b/src/applications/metamta/adapter/PhabricatorMailImplementationTestAdapter.php @@ -22,10 +22,6 @@ final class PhabricatorMailImplementationTestAdapter return array(); } - public function newLegacyOptions() { - return array(); - } - public function prepareForSend(array $config = array()) { $this->config = $config; } diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index e7ebf6dc83..36095f6aa8 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -520,53 +520,38 @@ final class PhabricatorMetaMTAMail $mailers = array(); $config = PhabricatorEnv::getEnvConfig('cluster.mailers'); - if ($config === null) { - $mailer = PhabricatorEnv::newObjectFromConfig('metamta.mail-adapter'); + + $adapters = PhabricatorMailImplementationAdapter::getAllAdapters(); + $next_priority = -1; + + foreach ($config as $spec) { + $type = $spec['type']; + if (!isset($adapters[$type])) { + throw new Exception( + pht( + 'Unknown mailer ("%s")!', + $type)); + } + + $key = $spec['key']; + $mailer = id(clone $adapters[$type]) + ->setKey($key); + + $priority = idx($spec, 'priority'); + if (!$priority) { + $priority = $next_priority; + $next_priority--; + } + $mailer->setPriority($priority); $defaults = $mailer->newDefaultOptions(); - $options = $mailer->newLegacyOptions(); + $options = idx($spec, 'options', array()) + $defaults; + $mailer->setOptions($options); - $options = $options + $defaults; - - $mailer - ->setKey('default') - ->setPriority(-1) - ->setOptions($options); + $mailer->setSupportsInbound(idx($spec, 'inbound', true)); + $mailer->setSupportsOutbound(idx($spec, 'outbound', true)); $mailers[] = $mailer; - } else { - $adapters = PhabricatorMailImplementationAdapter::getAllAdapters(); - $next_priority = -1; - - foreach ($config as $spec) { - $type = $spec['type']; - if (!isset($adapters[$type])) { - throw new Exception( - pht( - 'Unknown mailer ("%s")!', - $type)); - } - - $key = $spec['key']; - $mailer = id(clone $adapters[$type]) - ->setKey($key); - - $priority = idx($spec, 'priority'); - if (!$priority) { - $priority = $next_priority; - $next_priority--; - } - $mailer->setPriority($priority); - - $defaults = $mailer->newDefaultOptions(); - $options = idx($spec, 'options', array()) + $defaults; - $mailer->setOptions($options); - - $mailer->setSupportsInbound(idx($spec, 'inbound', true)); - $mailer->setSupportsOutbound(idx($spec, 'outbound', true)); - - $mailers[] = $mailer; - } } // Remove mailers with the wrong types. diff --git a/src/docs/user/configuration/configuration_locked.diviner b/src/docs/user/configuration/configuration_locked.diviner index fff0da9bdc..958124c381 100644 --- a/src/docs/user/configuration/configuration_locked.diviner +++ b/src/docs/user/configuration/configuration_locked.diviner @@ -82,7 +82,7 @@ access to fix any mistakes. attacker who has gained access to an administrator account in order to gain greater access. -For example, an attacker who could modify `metamta.mail-adapter` (and other +For example, an attacker who could modify `cluster.mailers` (and other similar options), could potentially reconfigure Phabricator to send mail through an evil server they controlled, then trigger password resets on other user accounts to compromise them. diff --git a/src/docs/user/configuration/configuring_inbound_email.diviner b/src/docs/user/configuration/configuring_inbound_email.diviner index f4f367d57e..869196e9d8 100644 --- a/src/docs/user/configuration/configuring_inbound_email.diviner +++ b/src/docs/user/configuration/configuring_inbound_email.diviner @@ -129,7 +129,7 @@ like this: - Add a Mailgun route with a `catch_all()` rule which takes the action `forward("https://phabricator.example.com/mail/mailgun/")`. Replace the example domain with your actual domain. - - Set the `mailgun.api-key` config key to your Mailgun API key. + - Configure a mailer in `cluster.mailers` with your Mailgun API key. Postmark Setup ==============