Example #1
0
 /**
  * Sends mail using Amazon SES.
  * @param string $header The message headers
  * @param string $body The message body
  * @access protected
  * @return bool
  */
 protected function AmazonSESSend($header, $body)
 {
     //$ses = @new AmazonSES($this->AWSAccessKeyID, $this->AWSSecretKey);
     $ses = new AmazonSES(array("key" => $this->AWSAccessKeyID, "secret" => $this->AWSSecretKey));
     if ($this->SingleTo === true) {
         foreach ($this->SingleToArray as $key => $val) {
             $response = $ses->send_raw_email(array('Data' => base64_encode($header . "\n" . $body)), array('Source' => $this->From, 'Destinations' => $val));
             // implement call back function if it exists
             $isSent = $response->isOK() ? 1 : 0;
             $this->doCallback($isSent, $val, $this->cc, $this->bcc, $this->Subject, $body);
             if (!$isSent) {
                 throw new phpmailerException('Error Sending via Amazon SES', self::STOP_CRITICAL);
             }
         }
     } else {
         $response = $ses->send_raw_email(array('Data' => base64_encode($header . "\n" . $body)), array('Source' => $this->From, 'Destinations' => $this->to));
         // implement call back function if it exists
         $isSent = $response->isOK() ? 1 : 0;
         $this->doCallback($isSent, $this->to, $this->cc, $this->bcc, $this->Subject, $body);
         if (!$isSent) {
             throw new phpmailerException('Error Sending via Amazon SES', self::STOP_CRITICAL);
         }
     }
     return true;
 }
function amazonSesEmail($to, $subject, $message)
{
    $amazonSes = new AmazonSES(array('key' => 'AKIAIMT5T3NIZUY2PKYQ', 'secret' => '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'));
    //$amazonSes->verify_email_address('*****@*****.**');
    $response = $amazonSes->send_email('*****@*****.**', array('ToAddresses' => array($to)), array('Subject.Data' => $subject, 'Body.Text.Data' => $message));
    if (!$response->isOK()) {
        echo "BAD";
    } else {
        echo "GOOD";
    }
}
 protected static function sendUsingAmazonSES()
 {
     ProjectConfiguration::registerAws();
     $email = new AmazonSES();
     $message = array('Subject.Data' => self::$_subject, 'Body.Text.Data' => self::$_message);
     $opt = array('ReplyToAddresses' => self::$_from);
     if (self::$_html_message) {
         $message['Body.Html.Data'] = self::$_html_message;
     }
     $response = $email->send_email(self::$_from, array('ToAddresses' => self::$_to), $message, $opt);
     return $response->isOK();
 }
 /**
  * Posts the data to the postmark API endpoint
  *
  * @return array
  * @throws CakeException
  */
 protected function _amazonSend()
 {
     $this->_generateAmazonSes();
     $response = $this->_amazonSes->send_raw_email($this->_data, $this->_dataOptions);
     if (!$response->isOK()) {
         throw new CakeException((string) $response->body->Error->Message);
     }
 }
function send_mail($to, $subject, $text, $from = MAILER_ADDRESS, $reply_to = ADMIN_ADDRESS)
{
    if (USE_NATIVE_MAIL) {
        if (is_array($to)) {
            $to = implode(', ', $to);
        }
        return mail($to, $subject, $text, "From:{$from}\nReply-to:{$reply_to}");
    } else {
        $message = array('Subject' => array('Data' => $subject), 'Body' => array('Text' => array('Data' => $text)));
        $opt = array('ReplyToAddresses' => $reply_to);
        if (!is_array($to)) {
            $to = array($to);
        }
        $ses = new AmazonSES();
        $ret = $ses->send_email($from, array('ToAddresses' => $to), $message, $opt);
        return $ret->isOK();
    }
}
 /**
  * Send mail
  *
  * @param CakeEmail $email CakeEmail
  * @return array
  * @throws SocketException When mail cannot be sent.
  */
 public function send(CakeEmail $email)
 {
     App::import('Vendor', 'Amazon', array('file' => 'AWSSDKforPHP/sdk.class.php'));
     $init_options['key'] = $this->_config['Amazon.SES.Key'];
     $init_options['secret'] = $this->_config['Amazon.SES.Secret'];
     $ses = new AmazonSES($init_options);
     $eol = PHP_EOL;
     if (isset($this->_config['eol'])) {
         $eol = $this->_config['eol'];
     }
     $option = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : array();
     $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
     $headers = $this->_headersToString($headers);
     $message = implode($eol, (array) $email->message());
     $raw_message = $headers . $eol . $eol . $message;
     $res = $ses->send_raw_email(array('Data' => base64_encode($raw_message)), $option);
     if ($res->status != 200) {
         CakeLog::write('error', var_export($res, 1));
         throw new SocketException(__d('cake_dev', 'Could not send email.'));
     }
     return array('headers' => $headers, 'message' => $message);
 }
Example #7
0
 function _aws_ses()
 {
     require_once APP . 'plugins/lark_utils/vendors/awssdk/sdk.class.php';
     $ses = new AmazonSES();
     $destination = array('ToAddresses' => explode(',', $this->to), 'CcAddresses' => $this->cc, 'BccAddresses' => $this->bcc);
     $message = array('Subject' => array('Data' => $this->subject), 'Body' => array());
     if ($this->textMessage != NULL) {
         $message['Body']['Text'] = array('Data' => $this->textMessage);
     }
     if ($this->htmlMessage != NULL) {
         $message['Body']['Html'] = array('Data' => $this->htmlMessage);
     }
     $opt = array();
     if (isset($this->replyTo)) {
         $opt['ReplyToAddresses'] = $this->replyTo;
     }
     $response = $ses->send_email($this->from, $destination, $message, $opt);
     $ok = $response->isOK();
     if (!$ok) {
         $this->log('Error sending email from AWS SES: ' . json_encode($response->body) . " Message was: " . $response->header['x-aws-body'], 'error');
     }
     return $ok;
 }
Example #8
0
 function send(Email $email)
 {
     $email = new \AmazonSES();
     $dest = array();
     $opt = array();
     $msg = array();
     if ($email->getRecipient()) {
         $opt['ToAddresses'] = explode(';', $email->getRecipient());
     }
     if ($email->getCc()) {
         $dest['CcAddresses'] = explode(';', $email->getCc());
     }
     if ($email->getBcc()) {
         $dest['BccAddresses'] = explode(';', $email->getBcc());
     }
     if ($email->getReplyTo()) {
         $opt['ReplyToAddresses'] = explode(';', $email->getReplyTo());
     }
     $msg['Subject.Data'] = $email->getSubject();
     $msg['Body.Text.Data'] = $email->getBody();
     return $email->send_email($email->getSender(), $dest, $msg, $opt);
 }
Example #9
0
 public function __construct()
 {
     $ses = new AmazonSES();
     $r = $ses->list_verified_email_addresses();
     var_dump($r);
 }