Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/storage/PhabricatorMetaMTAMail.php
| Show First 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | final class PhabricatorMetaMTAMail | ||||
| public function getRawToAddresses() { | public function getRawToAddresses() { | ||||
| return $this->getParam('raw-to', array()); | return $this->getParam('raw-to', array()); | ||||
| } | } | ||||
| public function getCcPHIDs() { | public function getCcPHIDs() { | ||||
| return $this->getParam('cc', array()); | return $this->getParam('cc', array()); | ||||
| } | } | ||||
| public function setMessageType($message_type) { | |||||
| return $this->setParam('message.type', $message_type); | |||||
| } | |||||
| public function getMessageType() { | |||||
| return $this->getParam( | |||||
| 'message.type', | |||||
| PhabricatorMailEmailMessage::MESSAGETYPE); | |||||
| } | |||||
| /** | /** | ||||
| * Force delivery of a message, even if recipients have preferences which | * Force delivery of a message, even if recipients have preferences which | ||||
| * would otherwise drop the message. | * would otherwise drop the message. | ||||
| * | * | ||||
| * This is primarily intended to let users who don't want any email still | * This is primarily intended to let users who don't want any email still | ||||
| * receive things like password resets. | * receive things like password resets. | ||||
| * | * | ||||
| * @param bool True to force delivery despite user preferences. | * @param bool True to force delivery despite user preferences. | ||||
| ▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | final class PhabricatorMetaMTAMail | ||||
| 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 = self::newMailers( | $mailers = self::newMailers( | ||||
| array( | array( | ||||
| 'outbound' => true, | 'outbound' => true, | ||||
| 'media' => array( | |||||
| $this->getMessageType(), | |||||
| ), | |||||
| )); | )); | ||||
| $try_mailers = $this->getParam('mailers.try'); | $try_mailers = $this->getParam('mailers.try'); | ||||
| if ($try_mailers) { | if ($try_mailers) { | ||||
| $mailers = mpull($mailers, null, 'getKey'); | $mailers = mpull($mailers, null, 'getKey'); | ||||
| $mailers = array_select_keys($mailers, $try_mailers); | $mailers = array_select_keys($mailers, $try_mailers); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | public function sendWithMailers(array $mailers) { | ||||
| // Attach any files we're about to send to this message, so the recipients | // Attach any files we're about to send to this message, so the recipients | ||||
| // can view them. | // can view them. | ||||
| $viewer = PhabricatorUser::getOmnipotentUser(); | $viewer = PhabricatorUser::getOmnipotentUser(); | ||||
| $files = $this->loadAttachedFiles($viewer); | $files = $this->loadAttachedFiles($viewer); | ||||
| foreach ($files as $file) { | foreach ($files as $file) { | ||||
| $file->attachToObject($this->getPHID()); | $file->attachToObject($this->getPHID()); | ||||
| } | } | ||||
| $type_map = PhabricatorMailExternalMessage::getAllMessageTypes(); | |||||
| $type = idx($type_map, $this->getMessageType()); | |||||
| if (!$type) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Unable to send message with unknown message type "%s".', | |||||
| $type)); | |||||
| } | |||||
| $exceptions = array(); | $exceptions = array(); | ||||
| foreach ($mailers as $mailer) { | foreach ($mailers as $mailer) { | ||||
| try { | try { | ||||
| $message = id(new PhabricatorMailEmailEngine()) | $message = $type->newMailMessageEngine() | ||||
| ->setMailer($mailer) | ->setMailer($mailer) | ||||
| ->setMail($this) | ->setMail($this) | ||||
| ->setActors($actors) | ->setActors($actors) | ||||
| ->setPreferences($preferences) | ->setPreferences($preferences) | ||||
| ->newMessage($mailer); | ->newMessage($mailer); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| $exceptions[] = $ex; | $exceptions[] = $ex; | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 528 Lines • Show Last 20 Lines | |||||