Changeset View
Changeset View
Standalone View
Standalone View
src/applications/metamta/adapter/PhabricatorMailAmazonSESAdapter.php
| <?php | <?php | ||||
| final class PhabricatorMailAmazonSESAdapter | final class PhabricatorMailAmazonSESAdapter | ||||
| extends PhabricatorMailSendmailAdapter { | extends PhabricatorMailAdapter { | ||||
| const ADAPTERTYPE = 'ses'; | const ADAPTERTYPE = 'ses'; | ||||
| private $message; | public function getSupportedMessageTypes() { | ||||
| private $isHTML; | return array( | ||||
| PhabricatorMailEmailMessage::MESSAGETYPE, | |||||
| public function prepareForSend() { | ); | ||||
| parent::prepareForSend(); | |||||
| $this->mailer->Mailer = 'amazon-ses'; | |||||
| $this->mailer->customMailer = $this; | |||||
| } | } | ||||
| public function supportsMessageIDHeader() { | public function supportsMessageIDHeader() { | ||||
| // Amazon SES will ignore any Message-ID we provide. | |||||
| return false; | return false; | ||||
| } | } | ||||
| protected function validateOptions(array $options) { | protected function validateOptions(array $options) { | ||||
| PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
| $options, | $options, | ||||
| array( | array( | ||||
| 'access-key' => 'string', | 'access-key' => 'string', | ||||
| 'secret-key' => 'string', | 'secret-key' => 'string', | ||||
| 'endpoint' => 'string', | 'endpoint' => 'string', | ||||
| 'encoding' => 'string', | |||||
| )); | )); | ||||
| } | } | ||||
| public function newDefaultOptions() { | public function newDefaultOptions() { | ||||
| return array( | return array( | ||||
| 'access-key' => null, | 'access-key' => null, | ||||
| 'secret-key' => null, | 'secret-key' => null, | ||||
| 'endpoint' => null, | 'endpoint' => null, | ||||
| 'encoding' => 'base64', | |||||
| ); | ); | ||||
| } | } | ||||
| /** | /** | ||||
| * @phutil-external-symbol class PHPMailerLite | |||||
| */ | |||||
| public function sendMessage(PhabricatorMailExternalMessage $message) { | |||||
| $root = phutil_get_library_root('phabricator'); | |||||
| $root = dirname($root); | |||||
| require_once $root.'/externals/phpmailer/class.phpmailer-lite.php'; | |||||
| $mailer = PHPMailerLite::newFromMessage($message); | |||||
| $mailer->Mailer = 'amazon-ses'; | |||||
| $mailer->customMailer = $this; | |||||
| $mailer->Send(); | |||||
| } | |||||
| /** | |||||
| * @phutil-external-symbol class SimpleEmailService | * @phutil-external-symbol class SimpleEmailService | ||||
| */ | */ | ||||
| public function executeSend($body) { | public function executeSend($body) { | ||||
| $key = $this->getOption('access-key'); | $key = $this->getOption('access-key'); | ||||
| $secret = $this->getOption('secret-key'); | $secret = $this->getOption('secret-key'); | ||||
| $endpoint = $this->getOption('endpoint'); | $endpoint = $this->getOption('endpoint'); | ||||
| $root = phutil_get_library_root('phabricator'); | $root = phutil_get_library_root('phabricator'); | ||||
| Show All 9 Lines | |||||