1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-07 13:21:02 +01:00
phorge-phorge/src/applications/config/check/PhabricatorMailSetupCheck.php
Chad Little b701313e0e Split Setup Issues into Groups
Summary: Groups setup issues into Important, PHP, MySQL, and Base for easier parsing on initial installations.

Test Plan:
Test my internal server and various issues.

{F289699}

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7207

Differential Revision: https://secure.phabricator.com/D11726
2015-02-10 12:53:00 -08:00

87 lines
3.5 KiB
PHP

<?php
final class PhabricatorMailSetupCheck extends PhabricatorSetupCheck {
public function getDefaultGroup() {
return self::GROUP_OTHER;
}
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)
->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');
}
$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;
}
}
}