1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Fix an issue with To/CC placeholders

Summary: Currently, if no placeholder is configured we always move "Cc" up to "To", even if we have a valid "To". Instead, move "Cc" to "To" only if there's no "To" and no placeholder.

Test Plan: Sent email with "to" and "cc", email with "cc" only with a placeholder, and email with "cc" only without a placeholder. Verified recipients ended up in the right location in all cases.

Reviewers: nh, btrahan

Reviewed By: btrahan

CC: klimek, aran

Differential Revision: https://secure.phabricator.com/D3342
This commit is contained in:
epriestley 2012-08-20 14:08:45 -07:00
parent e7796caa78
commit 21ebd1a609

View file

@ -616,22 +616,6 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
$add_cc = array_diff_key($add_cc, $exclude); $add_cc = array_diff_key($add_cc, $exclude);
} }
$empty_to =
PhabricatorEnv::getEnvConfig('metamta.placeholder-to-recipient');
if ($empty_to !== null && !$add_to) {
$mailer->addTos(array($empty_to));
}
if ($add_to) {
$mailer->addTos($add_to);
}
if ($add_cc) {
if ($empty_to !== null) {
$mailer->addCCs($add_cc);
} else {
$mailer->addTos($add_cc);
}
}
if (!$add_to && !$add_cc) { if (!$add_to && !$add_cc) {
$this->setStatus(self::STATUS_VOID); $this->setStatus(self::STATUS_VOID);
$this->setMessage( $this->setMessage(
@ -640,6 +624,24 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO {
return $this->save(); return $this->save();
} }
// Some mailers require a valid "To:" in order to deliver mail. If we
// don't have any "To:", try to fill it in with a placeholder "To:".
// If that also fails, move the "Cc:" line to "To:".
if (!$add_to) {
$placeholder_key = 'metamta.placeholder-to-recipient';
$placeholder = PhabricatorEnv::getEnvConfig($placeholder_key);
if ($placeholder !== null) {
$add_to = array($placeholder);
} else {
$add_to = $add_cc;
$add_cc = array();
}
}
$mailer->addTos($add_to);
if ($add_cc) {
$mailer->addCCs($add_cc);
}
} catch (Exception $ex) { } catch (Exception $ex) {
$this->setStatus(self::STATUS_FAIL); $this->setStatus(self::STATUS_FAIL);
$this->setMessage($ex->getMessage()); $this->setMessage($ex->getMessage());