Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
Show First 20 Lines • Show All 851 Lines • ▼ Show 20 Lines | foreach ($params as $key => $value) { | ||||
$mailer->setSubject(implode(' ', array_filter($subject))); | $mailer->setSubject(implode(' ', array_filter($subject))); | ||||
break; | break; | ||||
case 'thread-id': | case 'thread-id': | ||||
// NOTE: Gmail freaks out about In-Reply-To and References which | // NOTE: Gmail freaks out about In-Reply-To and References which | ||||
// aren't in the form "<string@domain.tld>"; this is also required | // aren't in the form "<string@domain.tld>"; this is also required | ||||
// by RFC 2822, although some clients are more liberal in what they | // by RFC 2822, although some clients are more liberal in what they | ||||
// accept. | // accept. | ||||
$domain = PhabricatorEnv::getEnvConfig('metamta.domain'); | $domain = $this->newMailDomain(); | ||||
$value = '<'.$value.'@'.$domain.'>'; | $value = '<'.$value.'@'.$domain.'>'; | ||||
if ($is_first && $mailer->supportsMessageIDHeader()) { | if ($is_first && $mailer->supportsMessageIDHeader()) { | ||||
$headers[] = array('Message-ID', $value); | $headers[] = array('Message-ID', $value); | ||||
} else { | } else { | ||||
$in_reply_to = $value; | $in_reply_to = $value; | ||||
$references = array($value); | $references = array($value); | ||||
$parent_id = $this->getParentMessageID(); | $parent_id = $this->getParentMessageID(); | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | if (PhabricatorEnv::getEnvConfig('phabricator.silent')) { | ||||
pht( | pht( | ||||
'Phabricator is running in silent mode. See `%s` '. | 'Phabricator is running in silent mode. See `%s` '. | ||||
'in the configuration to change this setting.', | 'in the configuration to change this setting.', | ||||
'phabricator.silent')); | 'phabricator.silent')); | ||||
return null; | return null; | ||||
} | } | ||||
// Some mailers require a valid "To:" in order to deliver mail. If we | // Some mailers require a valid "To:" in order to deliver mail. If we don't | ||||
// don't have any "To:", try to fill it in with a placeholder "To:". | // have any "To:", fill it in with a placeholder "To:". This allows client | ||||
// If that also fails, move the "Cc:" line to "To:". | // rules based on whether the recipient is in "To:" or "CC:" to continue | ||||
// behaving in the same way. | |||||
if (!$add_to) { | if (!$add_to) { | ||||
$placeholder_key = 'metamta.placeholder-to-recipient'; | $void_recipient = $this->newVoidEmailAddress(); | ||||
$placeholder = PhabricatorEnv::getEnvConfig($placeholder_key); | $add_to = array($void_recipient->getAddress()); | ||||
if ($placeholder !== null) { | |||||
$add_to = array($placeholder); | |||||
} else { | |||||
$add_to = $add_cc; | |||||
$add_cc = array(); | |||||
} | |||||
} | } | ||||
$add_to = array_unique($add_to); | $add_to = array_unique($add_to); | ||||
$add_cc = array_diff(array_unique($add_cc), $add_to); | $add_cc = array_diff(array_unique($add_cc), $add_to); | ||||
$mailer->addTos($add_to); | $mailer->addTos($add_to); | ||||
if ($add_cc) { | if ($add_cc) { | ||||
$mailer->addCCs($add_cc); | $mailer->addCCs($add_cc); | ||||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | private function filterHeaders(array $headers, $must_encrypt) { | ||||
return $headers; | return $headers; | ||||
} | } | ||||
public function getURI() { | public function getURI() { | ||||
return '/mail/detail/'.$this->getID().'/'; | return '/mail/detail/'.$this->getID().'/'; | ||||
} | } | ||||
private function newMailDomain() { | |||||
$install_uri = PhabricatorEnv::getURI('/'); | |||||
$install_uri = new PhutilURI($install_uri); | |||||
return $install_uri->getDomain(); | |||||
} | |||||
public function newVoidEmailAddress() { | |||||
$domain = $this->newMailDomain(); | |||||
$address = "void-recipient@{$domain}"; | |||||
amckinley: Are we worried about this potentially increasing the phacility.com bounce rate and randomly… | |||||
return new PhutilEmailAddress($address); | |||||
} | |||||
/* -( Routing )------------------------------------------------------------ */ | /* -( Routing )------------------------------------------------------------ */ | ||||
public function addRoutingRule($routing_rule, $phids, $reason_phid) { | public function addRoutingRule($routing_rule, $phids, $reason_phid) { | ||||
$routing = $this->getParam('routing', array()); | $routing = $this->getParam('routing', array()); | ||||
$routing[] = array( | $routing[] = array( | ||||
'routingRule' => $routing_rule, | 'routingRule' => $routing_rule, | ||||
▲ Show 20 Lines • Show All 149 Lines • Show Last 20 Lines |
Are we worried about this potentially increasing the phacility.com bounce rate and randomly killing our access to SendGrid/etc? I agree that this is an unlikely case to hit in any case so it probably won't matter.