From b4889259b7ac05be1e0fb88dfb707fcf82bc922b Mon Sep 17 00:00:00 2001 From: Stefano Azzolini Date: Fri, 10 Apr 2015 12:23:14 +0200 Subject: [PATCH] Update AeriaSES.php --- classes/AeriaSES.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/classes/AeriaSES.php b/classes/AeriaSES.php index cab9efa..ff1f30a 100755 --- a/classes/AeriaSES.php +++ b/classes/AeriaSES.php @@ -1,53 +1,45 @@ phpmailer = $phpmailer; } - public function Send() { // Build the raw email $this->phpmailer->preSend(); - try { - return AeriaSES::$client->sendRawEmail([ 'RawMessage' => [ // Get the builded RAW email (comprensive of headers) 'Data' => base64_encode($this->phpmailer->getSentMIMEMessage()) ] ]); - } catch (Exception $e) { // wp_mail() catch only phpmailerException - trigger_error($e->getMessage()); + trigger_error($e->getMessage(), E_WARNING); throw new phpmailerException($e->getMessage(), $e->getCode()); } } } - class AeriaSES { - public static $client = null; - + public static $config = []; public static function init($key, $secret, $region) { - require __DIR__.'/../vendor/aws.phar'; - static::$client = Aws\Ses\SesClient::factory(array( + static::$config = array( 'key' => $key, 'secret' => $secret, 'region' => $region - )); + ); } - public static function enable() { add_action('phpmailer_init', function(&$phpmailer) { + if (static::$client == null) { + require __DIR__.'/../vendor/aws.phar'; + static::$client = Aws\Ses\SesClient::factory(static::$config); + } $phpmailer = new SesClientProxyForPHPMailer($phpmailer); }); } - -} \ No newline at end of file +}