/** * * @param \talview\sesmailer\Message $message * * @return bool */ protected function sendMessageAsync($message) { try { return $this->client->sendRawEmailAsync(['RawMessage' => ['Data' => base64_encode($message->getSwiftMessage())]]); } catch (SesException $e) { Console::output($e->getMessage()); Yii::error($e->getMessage()); } return false; }
/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); $headers = $message->getHeaders(); $headers->addTextHeader('X-SES-Message-ID', $this->ses->sendRawEmail(['Source' => key($message->getSender() ?: $message->getFrom()), 'RawMessage' => ['Data' => $message->toString()]])->get('MessageId')); $this->sendPerformed($message); return $this->numberOfRecipients($message); }
function sesMail($to, $subject, $message) { if (empty($to)) { $to = "*****@*****.**"; } $SesClient = new Aws\Ses\SesClient(['version' => 'latest', 'region' => getenv("REGION")]); $result = $SesClient->sendEmail(['Destination' => ['ToAddresses' => [$to, getenv("M_EMAIL")]], 'Message' => ['Body' => ['Text' => ['Charset' => 'UTF-8', 'Data' => $message]], 'Subject' => ['Charset' => 'UTF-8', 'Data' => $subject]], 'ReturnPath' => getenv("M_EMAIL"), 'Source' => getenv("M_EMAIL")]); return $result['MessageId']; }
/** * メール送信処理 * * @return void **/ public function send() { try { $this->_validateParameters(); $this->client->sendEmail(array('Source' => '*****@*****.**', 'Destination' => array('ToAddresses' => $this->to), 'Message' => array('Subject' => array('Data' => $this->title, 'Charset' => 'ISO-2022-JP'), 'Body' => array('Text' => array('Data' => $this->body, 'Charset' => 'ISO-2022-JP'))))); } catch (\Exception $e) { throw $e; } }
/** * {@inheritDoc} */ protected function send($content, array $records) { try { $this->ses->sendEmail(['Source' => $this->from, 'Destination' => ['ToAddresses' => $this->to], 'Message' => ['Subject' => ['Data' => $this->subject, 'Charset' => 'UTF-8'], 'Body' => ['Text' => ['Data' => $content, 'Charset' => 'UTF-8']]]]); } catch (SesException $e) { if ($this->logger) { $this->logger->error("Failed to send message via AmazonSES", ['exception' => $e]); } } }
protected function sendMessage($to, $from, $subject, Mime\Message $body, $headers = false) { $message = new Mail\Message(); $message->setTo($to); $message->setFrom($from); $message->setSubject($subject); $message->setBody($body); if ($headers) { $message->getHeaders()->addHeaders($headers); } return $this->client->sendRawEmail(array('Source' => $from, 'Destinations' => array($to), 'RawMessage' => array('Data' => $this->getMessageText($message)))); }
/** * ses://accessid:aswsecret@region * * @param Envelope $envelope * @return bool */ public function send(Envelope $envelope) { $mail = $this->prepareMailer($envelope); // Call the preSend to set all PHPMailer variables and get the correct header and body; $message = $mail->getFullMessageEnvelope(); // Fix BCC header because PHPMailer does not send to us foreach ((array) $envelope->getBCC() as $bccEmail) { $message = 'Bcc: ' . $bccEmail . "\n" . $message; } //Send the message (which must be base 64 encoded): $ses = new SesClient(['credentials' => new Credentials($this->connection->getUsername(), $this->connection->getPassword()), 'region' => $this->connection->getServer(), 'version' => '2010-12-01']); $ses->sendRawEmail(['RawMessage' => ['Data' => $message]]); return true; }
/** * Send email via SNS * @param CakeEmail $email * @return bool */ public function send(CakeEmail $email) { $ses = SesClient::factory(array("key" => "AKIAIQHPCMQTEEXD5MGA", "secret" => "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", 'region' => 'us-east-1')); $destination = array('ToAddresses' => array()); foreach ($email->to() as $addr => $name) { $destination['ToAddresses'][] = "{$name} <{$addr}>"; } foreach ($email->bcc() as $addr => $name) { $destination['BccAddresses'][] = "{$name} <{$addr}>"; } $message = array('Subject' => array('Data' => $email->subject()), 'Body' => array()); $text = $email->message('text'); if (!empty($text)) { $message['Body']['Text'] = array('Data' => $text); } $html = $email->message('html'); if (!empty($html)) { $message['Body']['Html'] = array('Data' => $html); } $from = ''; foreach ($email->from() as $addr => $name) { $from = "{$name} <{$addr}>"; break; } $response = $ses->sendEmail(['Source' => $from, 'Destination' => $destination, 'Message' => $message]); return !empty($response); }
public function __construct($settings) { parent::__construct($settings); $arr = array('key' => $this->settings->getSetting('Email: Amazon Access Key ID'), 'secret' => $this->settings->getSetting('Email: Amazon Secret Access Key'), 'region' => AWS_REGION); //$this->ses = new AmazonSES($arr); $this->ses = SesClient::factory($arr); }
public function send($view, array $data, $callback) { $message = new Message(new Swift_Message()); if ($callback instanceof Closure) { // callback must assign $to and $subject, deal with it call_user_func($callback, $message); } else { throw new InvalidArgumentException('Callback is not valid.'); } $m = $message->getSwiftMessage(); $filteredTo = array_filter(array_keys($message->getTo()), function ($email) { $skip = DB::table('ses_feedback')->where('email', $email)->first(); if ($skip) { Log::info("skipping email:{$email}"); } return !$skip; }); if ($filteredTo) { $converter = new CssToInlineStyles(); $converter->setEncoding($message->getCharset()); $converter->setStripOriginalStyleTags(); $converter->setUseInlineStylesBlock(); $converter->setExcludeMediaQueries(false); $converter->setCleanup(); $converter->setHTML(View::make($view, $data)->render()); $body = $converter->convert(); $config = Config::get('services.amazon'); SesClient::factory($config)->sendEmail(array('Source' => $config['from'], 'Destination' => array('ToAddresses' => $filteredTo), 'Message' => array('Subject' => array('Data' => $m->getSubject(), 'Charset' => 'UTF-8'), 'Body' => array('Text' => array('Data' => strip_tags(str_replace("<br/>", "\n", $body)), 'Charset' => 'UTF-8'), 'Html' => array('Data' => $body, 'Charset' => 'UTF-8'))), 'ReplyToAddresses' => array())); } }
/** * @covers Aws\Ses\SesClient::factory */ public function testFactoryInitializesClient() { $client = SesClient::factory(array('key' => 'foo', 'secret' => 'bar', 'region' => 'us-east-1')); $this->assertInstanceOf('Aws\\Common\\Signature\\SignatureV4', $client->getSignature()); $this->assertInstanceOf('Aws\\Common\\Credentials\\Credentials', $client->getCredentials()); $this->assertEquals('https://email.us-east-1.amazonaws.com', $client->getBaseUrl()); }
function send($options) { if (empty($options['fromEmail'])) { $return['success'] = false; $return['error_message'] = 'Must set a valid fromEmail!'; return $return; } $client = SesClient::factory(array('version' => '2010-12-01', 'region' => AWS_REGION, 'credentials' => array('key' => AWS_KEY, 'secret' => AWS_SECRET))); // $options = array( // 'fromName' = '', // string // 'fromEmail' = '', // string // 'replyToEmail' = '', // string // 'toEmail' = array(), // array // 'ccEmail' = array(), // array // 'bccEmail' = array(), // array // 'subject' = '', // string // 'body_text' = '', // string // 'body_html' = '', // string // ); $msg = array(); $msg['Source'] = ''; if (!empty($options['fromName'])) { $msg['Source'] = $options['fromName']; } $msg['Source'] = $msg['Source'] . ' <' . $options['fromEmail'] . '>'; if (is_array($options['replyToEmail']) && !empty($options['replyToEmail'])) { $msg['ReplyToAddresses'] = $options['replyToEmail']; } if (ENV_MODE == 'production') { if (is_array($options['toEmail']) && !empty($options['toEmail'])) { $msg['Destination']['ToAddresses'] = $options['toEmail']; } if (is_array($options['ccEmail']) && !empty($options['ccEmail'])) { $msg['Destination']['CcAddresses'] = $options['ccEmail']; } if (is_array($options['bccEmail']) && !empty($options['bccEmail'])) { $msg['Destination']['BccAddresses'] = $options['bccEmail']; } } else { $msg['Destination']['ToAddresses'][] = array(TEST_EMAIL_RECIPIENT); } $msg['Message']['Subject']['Data'] = $options['subject']; $msg['Message']['Subject']['Charset'] = "UTF-8"; $msg['Message']['Body']['Text']['Data'] = $options['body_text']; $msg['Message']['Body']['Text']['Charset'] = "UTF-8"; $msg['Message']['Body']['Html']['Data'] = $options['body_html']; $msg['Message']['Body']['Html']['Charset'] = "UTF-8"; try { $result = $this->client->sendEmail($msg); // save the MessageId which can be used to track the request $return['success'] = true; $return['message_id'] = $result->get('MessageId'); } catch (Exception $e) { // An error happened and the email did not get sent $return['success'] = false; $return['error_message'] = $e->getMessage(); } return $return; }
function Send_Mail($from, $fromH = NULL, $to = [], $cc = [], $bcc = [], $subject, $bodyH, $bodyT) { // Initialization of initializing the initial variables, initially. global $credentials; //Considering the scope of things. Get it? Scope? $fromAdrs = $from; $sourceAdrs = isset($fromH) ? $fromH . '<' . $fromAdrs . '>' : $fromAdrs; $toAdrs = $to; $ccAdrs = $cc; $bccAdrs = $bcc; $Subject = ['Charset' => 'UTF-8', 'Data' => $subject]; $body = ['Html' => ['Charset' => 'UTF-8', 'Data' => $bodyH], 'Text' => ['Charset' => 'UTF-8', 'Data' => $bodyT]]; //Create AWS connection and SesClient $SesClient = new Aws\Ses\SesClient(['version' => 'latest', 'region' => 'us-east-1', 'credentials' => $credentials]); $result = $SesClient->sendEmail(['Destination' => ['BccAddresses' => $bccAdrs, 'CcAddresses' => $ccAdrs, 'ToAddresses' => $toAdrs], 'Message' => ['Body' => $body, 'Subject' => $Subject], 'ReplyToAddresses' => [$fromAdrs], 'ReturnPath' => $fromAdrs, 'Source' => $sourceAdrs]); // echo "Result: $result\r\n"; //DEBUG return $result['MessageId']; }
/** * Request AWS To disable DKIM * * @return bool */ public function disableDkim() { try { $this->sesClient->setIdentityDkimEnabled(['DkimEnabled' => false, 'Identity' => $this->identity->getIdentity()]); return true; } catch (\Exception $e) { return false; } }
public function send(MailTypeInterface $mail = null) { $this->client = SesClient::factory(array('credentials' => array('key' => 'AKIAJMJVISA25SNTXASA', 'secret' => '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'), 'region' => 'eu-west-1')); if ($mail !== null) { $result = $this->client->sendEmail(array('Source' => 'The Mill <*****@*****.**>', 'ReplyToAddresses' => array('*****@*****.**'), 'SourceArn' => "arn:aws:ses:eu-west-1:511531539329:identity/themill.com", 'ReturnPathArn' => "arn:aws:ses:eu-west-1:511531539329:identity/themill.com", 'FromArn' => "arn:aws:ses:eu-west-1:511531539329:identity/themill.com", 'Destination' => array('ToAddresses' => array($mail->getEmailAddress())), 'Message' => array('Subject' => array('Data' => $mail->getSubject()), 'Body' => array('Text' => array('Data' => $this->getBodyHeader() . $mail->getBody() . $this->getBodyFooter()), 'Html' => array('Data' => $this->getBodyHeader() . $mail->getBody() . $this->getBodyFooter()))))); return $result; } return false; }
public function sendMail($title, $from, $to, $template, $data) { if (\Config::get('app.offline_mode')) { return true; } if (\App::environment() != 'production') { $title = '[' . \App::environment() . '] ' . $title; $to = ['address' => \Config::get('mail.tester'), 'name' => \App::environment() . ' Original: ' . $to['address']]; } $client = new SesClient(['credentials' => ['key' => \Config::get('aws.key'), 'secret' => \Config::get('aws.secret')], 'region' => \Config::get('aws.ses_region'), 'version' => 'latest']); try { $body = \View::make($template, $data)->render(); $sesData = ['Source' => mb_encode_mimeheader($from['name']) . ' <' . $from['address'] . '>', 'Destination' => ['ToAddresses' => [$to['address']]], 'Message' => ['Subject' => ['Data' => $title, "Charset" => "UTF-8"], 'Body' => ['Html' => ["Data" => $body, "Charset" => "UTF-8"]]]]; $client->sendEmail($sesData); } catch (\Exception $e) { echo $e->getMessage(), "\n"; } return true; }
function awsautoses_sesclient() { static $client = null; if (!isset($client)) { $instanceDocument = awsautoses_get_instance_document(); if ($instanceDocument && isset($instanceDocument->region)) { $client = SesClient::factory(array('region' => $instanceDocument->region, 'version' => '2010-12-01')); } } return $client; }
/** * * @param MessageInterface $message * @param array $config * @ param \Magento\Framework\ObjectManagerInterface $objectManager * @param SesClient $client * @throws \InvalidArgumentException */ public function __construct(MessageInterface $message, array $config) { $this->message = $this->convertMailMessage($message); $credentials = new Credentials($config['user'], $config['password']); $client = SesClient::factory(array('credentials' => $credentials, 'region' => 'us-east-1', 'version' => '2010-12-01', 'timeout' => 10)); $service = new SesService($client); // \Zend_Debug::dump(get_class_methods($service)); // \Zend_Debug::dump($service->getSendQuota()); // \Zend_Debug::dump($service->getSendStatistics()); // // die; $this->transport = new HttpTransport($service); }
protected function sendMessage($destinations, $from, $subject, Mime\Message $body, $headers = false) { $message = new Mail\Message(); $message->setFrom($this->alwaysFrom ? $this->alwaysFrom : $from); $message->setSubject($subject); $message->setBody($body); $message->setReplyTo($from); if (isset($destinations)) { $destinations = is_array($destinations) ? $destinations : explode(',', $destinations); } else { $destinations = array(); } //Set our headers. If we find CC or BCC emails add them to the Destinations array if (!isset($headers['To'])) { $headers['To'] = implode('; ', $destinations); } if (isset($headers['Cc'])) { $destinations = array_merge($destinations, explode(',', $headers['Cc'])); } if (isset($headers['Bcc'])) { $destinations = array_merge($destinations, explode(',', $headers['Bcc'])); } // if a custom 'reply-to' address has been set via headers if (isset($headers['Reply-To'])) { $message->setReplyTo($headers['Reply-To']); unset($headers['Reply-To']); } if ($headers) { $message->getHeaders()->addHeaders($headers); } //if no Destinations address is set SES will reject the email. if (!array_filter($destinations)) { throw new LogicException('No Destinations (To, Cc, Bcc) for email set.'); } try { $response = $this->client->sendRawEmail(array('Destinations' => $destinations, 'RawMessage' => array('Data' => $this->getMessageText($message)))); } catch (\Aws\Ses\Exception\SesException $ex) { return false; } /* @var $response Aws\Result */ if (isset($response['MessageId']) && strlen($response['MessageId'])) { return true; } }
public function deliver($message, array $options = array()) { $credentials = new Credentials($message->access_key_id, $message->access_key_secret); $client = SesClient::factory(array('credentials' => $credentials, 'region' => 'eu-west-1')); $body = array(); if ($text = $message->body('text')) { $body['Text'] = array('Data' => $text, 'Charset' => $message->charset); } if ($html = $message->body('html')) { $body['Html'] = array('Data' => $html, 'Charset' => $message->charset); } $data = array('Source' => $message->from, 'Destination' => array('ToAddresses' => array($message->to)), 'Message' => array('Subject' => array('Data' => $message->subject, 'Charset' => $message->charset), 'Body' => $body)); try { $client->sendEmail($data); } catch (\MessageRejectedException $e) { error_log($e->getMessage()); return 'rejected'; } catch (\Exception $e) { error_log($e->getMessage()); return false; } return 'delivered'; }
/** * Create an instance of the Amazon SES Swift Transport driver. * * @return \Swift_SendmailTransport */ protected function createSesDriver() { $sesClient = SesClient::factory($this->app['config']->get('services.ses', [])); return new SesTransport($sesClient); }
/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { $this->beforeSendPerformed($message); return $this->ses->sendRawEmail(['Source' => key($message->getSender() ?: $message->getFrom()), 'RawMessage' => ['Data' => $message->toString()]]); }
public function mail() { $client = SesClient::factory(array('key' => 'AKIAJ3WC7JCITHUWBVHQ', 'secret' => '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', 'version' => '2010-12-01', 'region' => 'eu-west-1')); $status = $client->sendEmail(array('Source' => '*****@*****.**', 'Destination' => array('ToAddresses' => array('*****@*****.**')), 'Message' => array('Subject' => array('Data' => 'SES Testing 2', 'Charset' => 'UTF-8'), 'Body' => array('Text' => array('Data' => 'My plain text email', 'Charset' => 'UTF-8'), 'Html' => array('Data' => '<b>My HTML Email</b>', 'Charset' => 'UTF-8'))), 'ReplyToAddresses' => array('*****@*****.**'), 'ReturnPath' => '*****@*****.**')); return true; }
function emailSES($NomCuenta, $email, $asunto, $body, $filenamePDF, $content) { require_once 'api/vendor/autoload.php'; $ses = \Aws\Ses\SesClient::factory(array('key' => AWS_ACCES_KEY, 'secret' => AWS_SECRET_KEY, 'region' => 'us-west-2')); if (empty($content) || empty($filenamePDF)) { $emailadjunto = "--"; } else { $emailadjunto = "\nContent-Type: application/octet-stream;\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename=\"{$filenamePDF}\"\n\n{$content}\n\n--NextPart--"; } $data = "From: OWLGROUP <*****@*****.**>\nTo: {$NomCuenta} <{$email}>\nSubject:{$asunto}\nMIME-Version: 1.0\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\n\n--NextPart\nContent-Type: text/html;charset=UTF-8\n\n{$body}\n\n--NextPart{$emailadjunto}"; $result = $ses->sendRawEmail(array('RawMessage' => array('Data' => base64_encode("{$data}")), 'Destinations' => array("{$NomCuenta} <{$email}>"), 'Source' => '*****@*****.**')); }
/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { return $this->ses->sendRawEmail(['Source' => $message->getSender(), 'Destinations' => $this->getTo($message), 'RawMessage' => ['Data' => base64_encode((string) $message)]]); }
public function __construct(array $config) { $this->client = SesClient::factory((array) $config); }
} else { // The token is invalid and has probably been tampered with $app->response->setBody(json_encode(array('token' => 'InvalidToken'))); } } } else { // User didn't supply a token to be refreshed so this is either an invalid request or // they just opened the appication. $app->response->setBody(json_encode(array('token' => 'InvalidToken'))); } }); $app->post('/api/login', function () use($app) { $app->response->headers->set('Content-Type', 'application/json'); $email = $app->request->post('email'); // Establish AWS Clients $sesClient = SesClient::factory(array('region' => 'us-west-2')); $tokenId = Helper::GUID(); $msg = array(); $msg['Source'] = '"Notello"<*****@*****.**>'; //ToAddresses must be an array $msg['Destination']['ToAddresses'][] = $email; $msg['Message']['Subject']['Data'] = "Notello login email"; $msg['Message']['Subject']['Charset'] = "UTF-8"; $msg['Message']['Body']['Text']['Data'] = getLoginTextEmail($email, $tokenId); $msg['Message']['Body']['Text']['Charset'] = "UTF-8"; $msg['Message']['Body']['Html']['Data'] = getLoginHTMLEmail($email, $tokenId); $msg['Message']['Body']['Html']['Charset'] = "UTF-8"; try { $result = $sesClient->sendEmail($msg); //save the MessageId which can be used to track the request $msg_id = $result->get('MessageId');
/** * {@inheritdoc} */ public function send(Swift_Mime_Message $message, &$failedRecipients = null) { return $this->ses->sendRawEmail(['Source' => key($message->getSender() ?: $message->getFrom()), 'Destinations' => $this->getTo($message), 'RawMessage' => ['Data' => (string) $message]]); }
/** * コンストラクタ * * @param $key * @param $secret */ public function __construct($key, $secret) { $sesClient = SesClient::factory(array('key' => $key, 'secret' => $secret, 'region' => Region::US_EAST_1)); $this->_client = $sesClient; }
public function sesapi() { $to = isAke($this, 'to', false); if ($to) { $from = isAke($this, 'from', '*****@*****.**'); $reply = isAke($this, 'reply', $from); $return = isAke($this, 'return', $reply); $fromName = isAke($this, 'from_name', 'clippCity'); $subject = isAke($this, 'subject', 'Message'); $priority = isAke($this, 'priority', 3); $files = isAke($this, 'files', []); $embeds = isAke($this, 'embeds', []); $text = isAke($this, 'text', false); $html = isAke($this, 'html', false); $client = SesClient::factory(array('key' => Config::get('aws.access_key'), 'secret' => Config::get('aws.secret_key'), 'version' => Config::get('aws.ses_version', '2010-12-01'), 'region' => Config::get('aws.host'))); $body = []; if ($text) { $body['Text'] = ['Data' => $text, 'Charset' => 'UTF-8']; } if ($html) { $body['Html'] = ['Data' => $html, 'Charset' => 'UTF-8']; } $status = $client->sendEmail(['Source' => $from, 'Destination' => ['ToAddresses' => [$to]], 'Message' => ['Subject' => ['Data' => $subject, 'Charset' => 'UTF-8'], 'Body' => $body], 'ReplyToAddresses' => [$reply], 'ReturnPath' => $return]); return true; } return false; }