Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / metamta / adapter / PhabricatorMailAmazonSESAdapter.php
blobe5711e7e47736e6848926e9871cd0fc279b36671
1 <?php
3 final class PhabricatorMailAmazonSESAdapter
4 extends PhabricatorMailAdapter {
6 const ADAPTERTYPE = 'ses';
8 public function getSupportedMessageTypes() {
9 return array(
10 PhabricatorMailEmailMessage::MESSAGETYPE,
14 protected function validateOptions(array $options) {
15 PhutilTypeSpec::checkMap(
16 $options,
17 array(
18 'access-key' => 'string',
19 'secret-key' => 'string',
20 'region' => 'string',
21 'endpoint' => 'string',
22 ));
25 public function newDefaultOptions() {
26 return array(
27 'access-key' => null,
28 'secret-key' => null,
29 'region' => null,
30 'endpoint' => null,
34 /**
35 * @phutil-external-symbol class PHPMailerLite
37 public function sendMessage(PhabricatorMailExternalMessage $message) {
38 $root = phutil_get_library_root('phabricator');
39 $root = dirname($root);
40 require_once $root.'/externals/phpmailer/class.phpmailer-lite.php';
42 $mailer = PHPMailerLite::newFromMessage($message);
44 $mailer->Mailer = 'amazon-ses';
45 $mailer->customMailer = $this;
47 $mailer->Send();
50 public function executeSend($body) {
51 $key = $this->getOption('access-key');
53 $secret = $this->getOption('secret-key');
54 $secret = new PhutilOpaqueEnvelope($secret);
56 $region = $this->getOption('region');
57 $endpoint = $this->getOption('endpoint');
59 $data = array(
60 'Action' => 'SendRawEmail',
61 'RawMessage.Data' => base64_encode($body),
64 $data = phutil_build_http_querystring($data);
66 $future = id(new PhabricatorAWSSESFuture())
67 ->setAccessKey($key)
68 ->setSecretKey($secret)
69 ->setRegion($region)
70 ->setEndpoint($endpoint)
71 ->setHTTPMethod('POST')
72 ->setData($data);
74 $future->resolve();
76 return true;