Path: blob/master/src/applications/metamta/adapter/PhabricatorMailAmazonSESAdapter.php
12256 views
<?php12final class PhabricatorMailAmazonSESAdapter3extends PhabricatorMailAdapter {45const ADAPTERTYPE = 'ses';67public function getSupportedMessageTypes() {8return array(9PhabricatorMailEmailMessage::MESSAGETYPE,10);11}1213protected function validateOptions(array $options) {14PhutilTypeSpec::checkMap(15$options,16array(17'access-key' => 'string',18'secret-key' => 'string',19'region' => 'string',20'endpoint' => 'string',21));22}2324public function newDefaultOptions() {25return array(26'access-key' => null,27'secret-key' => null,28'region' => null,29'endpoint' => null,30);31}3233/**34* @phutil-external-symbol class PHPMailerLite35*/36public function sendMessage(PhabricatorMailExternalMessage $message) {37$root = phutil_get_library_root('phabricator');38$root = dirname($root);39require_once $root.'/externals/phpmailer/class.phpmailer-lite.php';4041$mailer = PHPMailerLite::newFromMessage($message);4243$mailer->Mailer = 'amazon-ses';44$mailer->customMailer = $this;4546$mailer->Send();47}4849public function executeSend($body) {50$key = $this->getOption('access-key');5152$secret = $this->getOption('secret-key');53$secret = new PhutilOpaqueEnvelope($secret);5455$region = $this->getOption('region');56$endpoint = $this->getOption('endpoint');5758$data = array(59'Action' => 'SendRawEmail',60'RawMessage.Data' => base64_encode($body),61);6263$data = phutil_build_http_querystring($data);6465$future = id(new PhabricatorAWSSESFuture())66->setAccessKey($key)67->setSecretKey($secret)68->setRegion($region)69->setEndpoint($endpoint)70->setHTTPMethod('POST')71->setData($data);7273$future->resolve();7475return true;76}7778}798081