mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
Move mail-related setup issues to setup checks
Summary: Ports mail stuff from the existing setup process to the more modular setup checks. Test Plan: Configured my local install to have all these errors, verified setup raised them. Reviewers: btrahan, vrana Reviewed By: btrahan CC: aran Maniphest Tasks: T2228 Differential Revision: https://secure.phabricator.com/D4494
This commit is contained in:
parent
2e589ebddc
commit
08bca2a87e
4 changed files with 85 additions and 113 deletions
|
@ -1206,6 +1206,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php',
|
'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php',
|
||||||
'PhabricatorSetupCheckExtraConfig' => 'applications/config/check/PhabricatorSetupCheckExtraConfig.php',
|
'PhabricatorSetupCheckExtraConfig' => 'applications/config/check/PhabricatorSetupCheckExtraConfig.php',
|
||||||
'PhabricatorSetupCheckInvalidConfig' => 'applications/config/check/PhabricatorSetupCheckInvalidConfig.php',
|
'PhabricatorSetupCheckInvalidConfig' => 'applications/config/check/PhabricatorSetupCheckInvalidConfig.php',
|
||||||
|
'PhabricatorSetupCheckMail' => 'applications/config/check/PhabricatorSetupCheckMail.php',
|
||||||
'PhabricatorSetupCheckTimezone' => 'applications/config/check/PhabricatorSetupCheckTimezone.php',
|
'PhabricatorSetupCheckTimezone' => 'applications/config/check/PhabricatorSetupCheckTimezone.php',
|
||||||
'PhabricatorSetupIssue' => 'applications/config/issue/PhabricatorSetupIssue.php',
|
'PhabricatorSetupIssue' => 'applications/config/issue/PhabricatorSetupIssue.php',
|
||||||
'PhabricatorSetupIssueView' => 'applications/config/view/PhabricatorSetupIssueView.php',
|
'PhabricatorSetupIssueView' => 'applications/config/view/PhabricatorSetupIssueView.php',
|
||||||
|
@ -2554,6 +2555,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupCheckExtraConfig' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckExtraConfig' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupCheckInvalidConfig' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckInvalidConfig' => 'PhabricatorSetupCheck',
|
||||||
|
'PhabricatorSetupCheckMail' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupCheckTimezone' => 'PhabricatorSetupCheck',
|
'PhabricatorSetupCheckTimezone' => 'PhabricatorSetupCheck',
|
||||||
'PhabricatorSetupIssueView' => 'AphrontView',
|
'PhabricatorSetupIssueView' => 'AphrontView',
|
||||||
'PhabricatorSlowvoteChoice' => 'PhabricatorSlowvoteDAO',
|
'PhabricatorSlowvoteChoice' => 'PhabricatorSlowvoteDAO',
|
||||||
|
|
|
@ -18,10 +18,6 @@ final class PhabricatorApplicationConfig extends PhabricatorApplication {
|
||||||
return self::GROUP_ADMIN;
|
return self::GROUP_ADMIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shouldAppearInLaunchView() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRoutes() {
|
public function getRoutes() {
|
||||||
return array(
|
return array(
|
||||||
'/config/' => array(
|
'/config/' => array(
|
||||||
|
|
83
src/applications/config/check/PhabricatorSetupCheckMail.php
Normal file
83
src/applications/config/check/PhabricatorSetupCheckMail.php
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorSetupCheckMail extends PhabricatorSetupCheck {
|
||||||
|
|
||||||
|
protected function executeChecks() {
|
||||||
|
$adapter = PhabricatorEnv::getEnvConfig('metamta.mail-adapter');
|
||||||
|
|
||||||
|
switch ($adapter) {
|
||||||
|
case 'PhabricatorMailImplementationPHPMailerLiteAdapter':
|
||||||
|
if (!Filesystem::pathExists('/usr/bin/sendmail') &&
|
||||||
|
!Filesystem::pathExists('/usr/sbin/sendmail')) {
|
||||||
|
$message = pht(
|
||||||
|
'Mail is configured to send via sendmail, but this system has '.
|
||||||
|
'no sendmail binary. Install sendmail or choose a different '.
|
||||||
|
'mail adapter.');
|
||||||
|
|
||||||
|
$this->newIssue('config.metamta.mail-adapter')
|
||||||
|
->setShortName(pht('Missing Sendmail'))
|
||||||
|
->setName(pht('No Sendmail Binary Found'))
|
||||||
|
->setMessage($message)
|
||||||
|
->addPhabricatorConfig('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)
|
||||||
|
->addPhabricatorConfig('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)
|
||||||
|
->addPhabricatorConfig('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)
|
||||||
|
->addPhabricatorConfig('metamta.mail-adapter')
|
||||||
|
->addPhabricatorConfig('amazon-ses.secret-key');
|
||||||
|
}
|
||||||
|
|
||||||
|
$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)
|
||||||
|
->addPhabricatorConfig('metamta.mail-adapter')
|
||||||
|
->addPhabricatorConfig('metamta.default-address');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -607,115 +607,6 @@ final class PhabricatorSetup {
|
||||||
|
|
||||||
self::write("[OKAY] Database and storage configuration OKAY\n");
|
self::write("[OKAY] Database and storage configuration OKAY\n");
|
||||||
|
|
||||||
|
|
||||||
self::writeHeader("OUTBOUND EMAIL CONFIGURATION");
|
|
||||||
|
|
||||||
$have_adapter = false;
|
|
||||||
$is_ses = false;
|
|
||||||
|
|
||||||
$adapter = PhabricatorEnv::getEnvConfig('metamta.mail-adapter');
|
|
||||||
switch ($adapter) {
|
|
||||||
case 'PhabricatorMailImplementationPHPMailerLiteAdapter':
|
|
||||||
|
|
||||||
$have_adapter = true;
|
|
||||||
|
|
||||||
if (!Filesystem::pathExists('/usr/bin/sendmail') &&
|
|
||||||
!Filesystem::pathExists('/usr/sbin/sendmail')) {
|
|
||||||
self::writeFailure();
|
|
||||||
self::write(
|
|
||||||
"Setup failure! You don't have a 'sendmail' binary on this system ".
|
|
||||||
"but outbound email is configured to use sendmail. Install an MTA ".
|
|
||||||
"(like sendmail, qmail or postfix) or use a different outbound ".
|
|
||||||
"mail configuration. See this guide for configuring outbound ".
|
|
||||||
"email:\n");
|
|
||||||
self::writeDoc('article/Configuring_Outbound_Email.html');
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
self::write(" okay Sendmail is configured.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 'PhabricatorMailImplementationAmazonSESAdapter':
|
|
||||||
|
|
||||||
$is_ses = true;
|
|
||||||
$have_adapter = true;
|
|
||||||
|
|
||||||
if (PhabricatorEnv::getEnvConfig('metamta.can-send-as-user')) {
|
|
||||||
self::writeFailure();
|
|
||||||
self::write(
|
|
||||||
"Setup failure! 'metamta.can-send-as-user' must be false when ".
|
|
||||||
"configured with Amazon SES.");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
self::write(" okay Sender config looks okay.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PhabricatorEnv::getEnvConfig('amazon-ses.access-key')) {
|
|
||||||
self::writeFailure();
|
|
||||||
self::write(
|
|
||||||
"Setup failure! 'amazon-ses.access-key' is not set, but ".
|
|
||||||
"outbound mail is configured to deliver via Amazon SES.");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
self::write(" okay Amazon SES access key is set.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PhabricatorEnv::getEnvConfig('amazon-ses.secret-key')) {
|
|
||||||
self::writeFailure();
|
|
||||||
self::write(
|
|
||||||
"Setup failure! 'amazon-ses.secret-key' is not set, but ".
|
|
||||||
"outbound mail is configured to deliver via Amazon SES.");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
self::write(" okay Amazon SES secret key is set.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PhabricatorEnv::getEnvConfig('metamta.send-immediately')) {
|
|
||||||
self::writeNote(
|
|
||||||
"Your configuration uses Amazon SES to deliver email but tries ".
|
|
||||||
"to send it immediately. This will work, but it's slow. ".
|
|
||||||
"Consider configuring the MetaMTA daemon.");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'PhabricatorMailImplementationTestAdapter':
|
|
||||||
self::write(" skip You have disabled outbound email.\n");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
self::write(" skip Configured with a custom adapter.\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($have_adapter) {
|
|
||||||
$default = PhabricatorEnv::getEnvConfig('metamta.default-address');
|
|
||||||
if (!$default || $default == 'noreply@example.com') {
|
|
||||||
self::writeFailure();
|
|
||||||
self::write(
|
|
||||||
"Setup failure! You have not set 'metamta.default-address'.");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
self::write(" okay metamta.default-address is set.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($is_ses) {
|
|
||||||
self::writeNote(
|
|
||||||
"Make sure you've verified your 'from' address ('{$default}') with ".
|
|
||||||
"Amazon SES. Until you verify it, you will be unable to send mail ".
|
|
||||||
"using Amazon SES.");
|
|
||||||
}
|
|
||||||
|
|
||||||
$domain = PhabricatorEnv::getEnvConfig('metamta.domain');
|
|
||||||
if (!$domain || $domain == 'example.com') {
|
|
||||||
self::writeFailure();
|
|
||||||
self::write(
|
|
||||||
"Setup failure! You have not set 'metamta.domain'.");
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
self::write(" okay metamta.domain is set.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
self::write("[OKAY] Mail configuration OKAY\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
self::writeHeader('SUCCESS!');
|
self::writeHeader('SUCCESS!');
|
||||||
self::write(
|
self::write(
|
||||||
"Congratulations! Your setup seems mostly correct, or at least fairly ".
|
"Congratulations! Your setup seems mostly correct, or at least fairly ".
|
||||||
|
|
Loading…
Reference in a new issue