Skip to content

Instantly share code, notes, and snippets.

@skynet
Forked from kopiro/wpmail.php
Last active August 29, 2015 14:13
Show Gist options
  • Save skynet/e43276cb9456a88fc98b to your computer and use it in GitHub Desktop.
Save skynet/e43276cb9456a88fc98b to your computer and use it in GitHub Desktop.
<?php
$ses = Aws\Ses\SesClient::factory(array(
'key' => SES_KEY,
'secret' => SES_SECRET,
'region' => SES_REGION
));
class SesClientProxyForPHPMailer {
private $phpmailer;
public function __construct($phpmailer) {
$this->phpmailer = $phpmailer;
}
public function Send() {
global $ses;
$this->phpmailer->preSend();
try {
return $ses->sendRawEmail([
'RawMessage' => [ 'Data' => base64_encode($this->phpmailer->getSentMIMEMessage()) ]
]);
} catch (Exception $e) {
trigger_error($e->getMessage());
throw new phpmailerException($e->getMessage(), $e->getCode());
}
}
}
add_action('phpmailer_init', function(&$phpmailer) {
$phpmailer = new SesClientProxyForPHPMailer($phpmailer);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment