diff --git a/conf/default.conf.php b/conf/default.conf.php index ce8580c5d6..1df780db15 100644 --- a/conf/default.conf.php +++ b/conf/default.conf.php @@ -320,6 +320,14 @@ return array( // configuration a little easier. 'metamta.send-immediately' => true, + // When email is sent, what format should Phabricator use for user's + // email addresses? Valid values are: + // - 'short' - 'gwashington ' + // - 'real' - 'George Washington ' + // - 'full' - 'gwashington (George Washington) ' + // The default is 'full'. + 'metamta.user-address-format' => 'full', + // If you're using Amazon SES to send email, provide your AWS access key // and AWS secret key here. To set up Amazon SES with Phabricator, you need // to: diff --git a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php index f99fe17414..da7d2ef889 100644 --- a/src/applications/metamta/storage/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/PhabricatorMetaMTAMail.php @@ -758,7 +758,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { case PhabricatorPHIDConstants::PHID_TYPE_USER: $user = $users[$phid]; if ($user) { - $name = $user->getFullName(); + $name = $this->getUserName($user); $is_mailable = !$user->getIsDisabled() && !$user->getIsSystemAgent(); } @@ -783,6 +783,32 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { } } + /** + * Small helper function to make sure we format the username properly as + * specified by the `metamta.user-address-format` configuration value. + */ + private function getUserName($user) { + $format = PhabricatorEnv::getEnvConfig( + 'metamta.user-address-format', + 'full' + ); + + switch ($format) { + case 'short': + $name = $user->getUserName(); + break; + case 'real': + $name = $user->getRealName(); + break; + case 'full': + default: + $name = $user->getFullName(); + break; + } + + return $name; + } + private function filterSendable($value, $phids, $exclude) { $result = array(); foreach ($value as $phid) {