@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+85 -113
+2
src/__phutil_library_map__.php
··· 1206 1206 'PhabricatorSetupCheckAPC' => 'applications/config/check/PhabricatorSetupCheckAPC.php', 1207 1207 'PhabricatorSetupCheckExtraConfig' => 'applications/config/check/PhabricatorSetupCheckExtraConfig.php', 1208 1208 'PhabricatorSetupCheckInvalidConfig' => 'applications/config/check/PhabricatorSetupCheckInvalidConfig.php', 1209 + 'PhabricatorSetupCheckMail' => 'applications/config/check/PhabricatorSetupCheckMail.php', 1209 1210 'PhabricatorSetupCheckTimezone' => 'applications/config/check/PhabricatorSetupCheckTimezone.php', 1210 1211 'PhabricatorSetupIssue' => 'applications/config/issue/PhabricatorSetupIssue.php', 1211 1212 'PhabricatorSetupIssueView' => 'applications/config/view/PhabricatorSetupIssueView.php', ··· 2554 2555 'PhabricatorSetupCheckAPC' => 'PhabricatorSetupCheck', 2555 2556 'PhabricatorSetupCheckExtraConfig' => 'PhabricatorSetupCheck', 2556 2557 'PhabricatorSetupCheckInvalidConfig' => 'PhabricatorSetupCheck', 2558 + 'PhabricatorSetupCheckMail' => 'PhabricatorSetupCheck', 2557 2559 'PhabricatorSetupCheckTimezone' => 'PhabricatorSetupCheck', 2558 2560 'PhabricatorSetupIssueView' => 'AphrontView', 2559 2561 'PhabricatorSlowvoteChoice' => 'PhabricatorSlowvoteDAO',
-4
src/applications/config/application/PhabricatorApplicationConfig.php
··· 18 18 return self::GROUP_ADMIN; 19 19 } 20 20 21 - public function shouldAppearInLaunchView() { 22 - return false; 23 - } 24 - 25 21 public function getRoutes() { 26 22 return array( 27 23 '/config/' => array(
+83
src/applications/config/check/PhabricatorSetupCheckMail.php
··· 1 + <?php 2 + 3 + final class PhabricatorSetupCheckMail extends PhabricatorSetupCheck { 4 + 5 + protected function executeChecks() { 6 + $adapter = PhabricatorEnv::getEnvConfig('metamta.mail-adapter'); 7 + 8 + switch ($adapter) { 9 + case 'PhabricatorMailImplementationPHPMailerLiteAdapter': 10 + if (!Filesystem::pathExists('/usr/bin/sendmail') && 11 + !Filesystem::pathExists('/usr/sbin/sendmail')) { 12 + $message = pht( 13 + 'Mail is configured to send via sendmail, but this system has '. 14 + 'no sendmail binary. Install sendmail or choose a different '. 15 + 'mail adapter.'); 16 + 17 + $this->newIssue('config.metamta.mail-adapter') 18 + ->setShortName(pht('Missing Sendmail')) 19 + ->setName(pht('No Sendmail Binary Found')) 20 + ->setMessage($message) 21 + ->addPhabricatorConfig('metamta.mail-adapter'); 22 + } 23 + break; 24 + case 'PhabricatorMailImplementationAmazonSESAdapter': 25 + if (PhabricatorEnv::getEnvConfig('metamta.can-send-as-user')) { 26 + $message = pht( 27 + 'Amazon SES does not support sending email as users. Disable '. 28 + 'send as user, or choose a different mail adapter.'); 29 + 30 + $this->newIssue('config.can-send-as-user') 31 + ->setName(pht("SES Can't Send As User")) 32 + ->setMessage($message) 33 + ->addPhabricatorConfig('metamta.mail-adapter') 34 + ->addPhabricatorConfig('metamta.can-send-as-user'); 35 + } 36 + 37 + if (!PhabricatorEnv::getEnvConfig('amazon-ses.access-key')) { 38 + $message = pht( 39 + 'Amazon SES is selected as the mail adapter, but no SES access '. 40 + 'key is configured. Provide an SES access key, or choose a '. 41 + 'different mail adapter.'); 42 + 43 + $this->newIssue('config.amazon-ses.access-key') 44 + ->setName(pht("Amazon SES Access Key Not Set")) 45 + ->setMessage($message) 46 + ->addPhabricatorConfig('metamta.mail-adapter') 47 + ->addPhabricatorConfig('amazon-ses.access-key'); 48 + } 49 + 50 + if (!PhabricatorEnv::getEnvConfig('amazon-ses.secret-key')) { 51 + $message = pht( 52 + 'Amazon SES is selected as the mail adapter, but no SES secret '. 53 + 'key is configured. Provide an SES secret key, or choose a '. 54 + 'different mail adapter.'); 55 + 56 + $this->newIssue('config.amazon-ses.secret-key') 57 + ->setName(pht("Amazon SES Secret Key Not Set")) 58 + ->setMessage($message) 59 + ->addPhabricatorConfig('metamta.mail-adapter') 60 + ->addPhabricatorConfig('amazon-ses.secret-key'); 61 + } 62 + 63 + $address_key = 'metamta.default-address'; 64 + $options = PhabricatorApplicationConfigOptions::loadAllOptions(); 65 + $default = $options[$address_key]->getDefault(); 66 + $value = PhabricatorEnv::getEnvConfig($address_key); 67 + if ($default === $value) { 68 + $message = pht( 69 + 'Amazon SES requires verification of the "From" address, but '. 70 + 'you have not configured a "From" address. Configure and verify '. 71 + 'a "From" address, or choose a different mail adapter.'); 72 + 73 + $this->newIssue('config.metamta.default-address') 74 + ->setName(pht("No SES From Address Configured")) 75 + ->setMessage($message) 76 + ->addPhabricatorConfig('metamta.mail-adapter') 77 + ->addPhabricatorConfig('metamta.default-address'); 78 + } 79 + break; 80 + } 81 + 82 + } 83 + }
-109
src/infrastructure/PhabricatorSetup.php
··· 607 607 608 608 self::write("[OKAY] Database and storage configuration OKAY\n"); 609 609 610 - 611 - self::writeHeader("OUTBOUND EMAIL CONFIGURATION"); 612 - 613 - $have_adapter = false; 614 - $is_ses = false; 615 - 616 - $adapter = PhabricatorEnv::getEnvConfig('metamta.mail-adapter'); 617 - switch ($adapter) { 618 - case 'PhabricatorMailImplementationPHPMailerLiteAdapter': 619 - 620 - $have_adapter = true; 621 - 622 - if (!Filesystem::pathExists('/usr/bin/sendmail') && 623 - !Filesystem::pathExists('/usr/sbin/sendmail')) { 624 - self::writeFailure(); 625 - self::write( 626 - "Setup failure! You don't have a 'sendmail' binary on this system ". 627 - "but outbound email is configured to use sendmail. Install an MTA ". 628 - "(like sendmail, qmail or postfix) or use a different outbound ". 629 - "mail configuration. See this guide for configuring outbound ". 630 - "email:\n"); 631 - self::writeDoc('article/Configuring_Outbound_Email.html'); 632 - return; 633 - } else { 634 - self::write(" okay Sendmail is configured.\n"); 635 - } 636 - 637 - break; 638 - case 'PhabricatorMailImplementationAmazonSESAdapter': 639 - 640 - $is_ses = true; 641 - $have_adapter = true; 642 - 643 - if (PhabricatorEnv::getEnvConfig('metamta.can-send-as-user')) { 644 - self::writeFailure(); 645 - self::write( 646 - "Setup failure! 'metamta.can-send-as-user' must be false when ". 647 - "configured with Amazon SES."); 648 - return; 649 - } else { 650 - self::write(" okay Sender config looks okay.\n"); 651 - } 652 - 653 - if (!PhabricatorEnv::getEnvConfig('amazon-ses.access-key')) { 654 - self::writeFailure(); 655 - self::write( 656 - "Setup failure! 'amazon-ses.access-key' is not set, but ". 657 - "outbound mail is configured to deliver via Amazon SES."); 658 - return; 659 - } else { 660 - self::write(" okay Amazon SES access key is set.\n"); 661 - } 662 - 663 - if (!PhabricatorEnv::getEnvConfig('amazon-ses.secret-key')) { 664 - self::writeFailure(); 665 - self::write( 666 - "Setup failure! 'amazon-ses.secret-key' is not set, but ". 667 - "outbound mail is configured to deliver via Amazon SES."); 668 - return; 669 - } else { 670 - self::write(" okay Amazon SES secret key is set.\n"); 671 - } 672 - 673 - if (PhabricatorEnv::getEnvConfig('metamta.send-immediately')) { 674 - self::writeNote( 675 - "Your configuration uses Amazon SES to deliver email but tries ". 676 - "to send it immediately. This will work, but it's slow. ". 677 - "Consider configuring the MetaMTA daemon."); 678 - } 679 - break; 680 - case 'PhabricatorMailImplementationTestAdapter': 681 - self::write(" skip You have disabled outbound email.\n"); 682 - break; 683 - default: 684 - self::write(" skip Configured with a custom adapter.\n"); 685 - break; 686 - } 687 - 688 - if ($have_adapter) { 689 - $default = PhabricatorEnv::getEnvConfig('metamta.default-address'); 690 - if (!$default || $default == 'noreply@example.com') { 691 - self::writeFailure(); 692 - self::write( 693 - "Setup failure! You have not set 'metamta.default-address'."); 694 - return; 695 - } else { 696 - self::write(" okay metamta.default-address is set.\n"); 697 - } 698 - 699 - if ($is_ses) { 700 - self::writeNote( 701 - "Make sure you've verified your 'from' address ('{$default}') with ". 702 - "Amazon SES. Until you verify it, you will be unable to send mail ". 703 - "using Amazon SES."); 704 - } 705 - 706 - $domain = PhabricatorEnv::getEnvConfig('metamta.domain'); 707 - if (!$domain || $domain == 'example.com') { 708 - self::writeFailure(); 709 - self::write( 710 - "Setup failure! You have not set 'metamta.domain'."); 711 - return; 712 - } else { 713 - self::write(" okay metamta.domain is set.\n"); 714 - } 715 - 716 - self::write("[OKAY] Mail configuration OKAY\n"); 717 - } 718 - 719 610 self::writeHeader('SUCCESS!'); 720 611 self::write( 721 612 "Congratulations! Your setup seems mostly correct, or at least fairly ".