Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
Show First 20 Lines • Show All 447 Lines • ▼ Show 20 Lines | $mailer_task = PhabricatorWorker::scheduleTask( | ||||
$this->getID(), | $this->getID(), | ||||
array( | array( | ||||
'priority' => PhabricatorWorker::PRIORITY_ALERTS, | 'priority' => PhabricatorWorker::PRIORITY_ALERTS, | ||||
)); | )); | ||||
return $result; | return $result; | ||||
} | } | ||||
public function buildDefaultMailer() { | |||||
return PhabricatorEnv::newObjectFromConfig('metamta.mail-adapter'); | |||||
} | |||||
/** | /** | ||||
* Attempt to deliver an email immediately, in this process. | * Attempt to deliver an email immediately, in this process. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function sendNow() { | public function sendNow() { | ||||
if ($this->getStatus() != PhabricatorMailOutboundStatus::STATUS_QUEUE) { | if ($this->getStatus() != PhabricatorMailOutboundStatus::STATUS_QUEUE) { | ||||
throw new Exception(pht('Trying to send an already-sent mail!')); | throw new Exception(pht('Trying to send an already-sent mail!')); | ||||
} | } | ||||
$mailers = array( | $mailers = $this->newMailers(); | ||||
$this->buildDefaultMailer(), | |||||
); | |||||
return $this->sendWithMailers($mailers); | return $this->sendWithMailers($mailers); | ||||
} | } | ||||
private function newMailers() { | |||||
$mailers = array(); | |||||
$mailer = PhabricatorEnv::newObjectFromConfig('metamta.mail-adapter'); | |||||
$defaults = $mailer->newDefaultOptions(); | |||||
$options = $mailer->newLegacyOptions(); | |||||
$options = $options + $defaults; | |||||
$mailer | |||||
->setKey('default') | |||||
->setOptions($options); | |||||
$mailer->prepareForSend(); | |||||
$mailers[] = $mailer; | |||||
return $mailers; | |||||
} | |||||
public function sendWithMailers(array $mailers) { | public function sendWithMailers(array $mailers) { | ||||
$exceptions = array(); | $exceptions = array(); | ||||
foreach ($mailers as $template_mailer) { | foreach ($mailers as $template_mailer) { | ||||
$mailer = null; | $mailer = null; | ||||
try { | try { | ||||
$mailer = $this->buildMailer($template_mailer); | $mailer = $this->buildMailer($template_mailer); | ||||
▲ Show 20 Lines • Show All 929 Lines • Show Last 20 Lines |