/**
  * Sends out email via Mandrill
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     $message = array('html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'from_email' => $fromEmail, 'from_name' => $fromName, 'to' => array(), 'headers' => array('Reply-To' => $fromEmail), 'important' => false, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true, 'tags' => null, 'subaccount' => null);
     $message = array_merge($message, $this->_headers);
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'to');
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'cc');
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'bcc');
     }
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'content' => base64_encode(file_get_contents($data['file'])));
         }
     }
     $params = array('message' => $message, "async" => false, "ip_pool" => null, "send_at" => null);
     return $this->_exec($params);
 }
 /**
  * Sends out email via Mandrill
  *
  * @return array Return the Mandrill
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders(array('from', 'to', 'cc', 'bcc', 'replyTo', 'subject'));
     // Setup connection
     $this->__mandrillConnection =& new HttpSocket();
     // Build message
     $message = $this->__buildMessage();
     // Build request
     $request = $this->__buildRequest();
     if (isset($this->_config['mandrillTemplate']) && !empty($this->_config['mandrillTemplate'])) {
         $message_send_uri = $this->_config['uri'] . "messages/send-template.json";
     } else {
         $message_send_uri = $this->_config['uri'] . "messages/send.json";
     }
     // Send message
     try {
         $returnMandrill = $this->__mandrillConnection->post($message_send_uri, json_encode($message), $request);
         // Return data
         $result = json_decode($returnMandrill, true);
         $headers = $this->_headersToString($this->_headers);
         return array_merge(array('Mandrill' => $result), array('headers' => $headers, 'message' => $message));
     } catch (Exception $e) {
         return false;
     }
 }
 /**
  * Sends out email via Mandrill
  *
  * @return array Return the Mandrill
  */
 public function send(CakeEmail $email)
 {
     $this->_Email = $email;
     $this->_config = $this->_Email->config() + (array) Configure::read('Mandrill');
     if (empty($this->_config['apiKey'])) {
         throw new InternalErrorException('No API key');
     }
     if (empty($this->_config['uri'])) {
         $this->_config['uri'] = static::API_URL;
     }
     $include = ['from', 'to', 'cc', 'bcc', 'replyTo', 'subject'];
     $this->_headers = $this->_Email->getHeaders($include);
     $message = $this->_buildMessage();
     $request = ['header' => ['Accept' => 'application/json', 'Content-Type' => 'application/json']];
     $template = $this->_Email->template();
     if ($template['template'] && !empty($this->_config['useTemplate'])) {
         $messageUri = $this->_config['uri'] . "messages/send-template.json";
     } else {
         $messageUri = $this->_config['uri'] . "messages/send.json";
     }
     // Perform the http connection
     $returnMandrill = $this->_post($messageUri, $message, $request);
     // Parse mandrill results
     $result = json_decode($returnMandrill, true);
     if (!empty($this->_config['log'])) {
         CakeLog::write('mandrill', print_r($result, true));
     }
     $headers = $this->_headersToString($this->_headers);
     return array_merge(['Mandrill' => $result], ['headers' => $headers, 'message' => $message]);
 }
 public static function email($data)
 {
     try {
         $email = new CakeEmail();
         $email->config(!empty($data['settings']) ? $data['settings'] : 'default');
         $email->config($data)->send();
     } catch (Exception $e) {
         return json_encode($email) . ' ' . $e->getMessage();
     }
     return true;
 }
 /**
  * Sends out email via SparkPost
  *
  * @param CakeEmail $email
  * @return array
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders();
     // Not allowed by SparkPost
     unset($this->_headers['Content-Type']);
     unset($this->_headers['Content-Transfer-Encoding']);
     unset($this->_headers['MIME-Version']);
     unset($this->_headers['X-Mailer']);
     $from = $this->_cakeEmail->from();
     list($fromEmail) = array_keys($from);
     $fromName = $from[$fromEmail];
     $message = ['html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'from' => ['name' => $fromName, 'email' => $fromEmail], 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'recipients' => [], 'transactional' => true];
     foreach ($this->_cakeEmail->to() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     foreach ($this->_cakeEmail->cc() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     foreach ($this->_cakeEmail->bcc() as $email => $name) {
         $message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
     }
     unset($this->_headers['tags']);
     $attachments = $this->_cakeEmail->attachments();
     if (!empty($attachments)) {
         $message['attachments'] = array();
         foreach ($attachments as $file => $data) {
             if (!empty($data['contentId'])) {
                 $message['inlineImages'][] = array('type' => $data['mimetype'], 'name' => $data['contentId'], 'data' => base64_encode(file_get_contents($data['file'])));
             } else {
                 $message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'data' => base64_encode(file_get_contents($data['file'])));
             }
         }
     }
     $message = array_merge($message, $this->_headers);
     // Load SparkPost configuration settings
     $config = ['key' => $this->_config['sparkpost']['api_key']];
     if (isset($this->_config['sparkpost']['timeout'])) {
         $config['timeout'] = $this->_config['sparkpost']['timeout'];
     }
     // Set up HTTP request adapter
     $httpAdapter = new Ivory\HttpAdapter\Guzzle6HttpAdapter($this->__getClient());
     // Create SparkPost API accessor
     $sparkpost = new SparkPost\SparkPost($httpAdapter, $config);
     // Send message
     try {
         return $sparkpost->transmission->send($message);
     } catch (SparkPost\APIResponseException $e) {
         // TODO: Determine if BRE is the best exception type
         throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)', $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
     }
 }
 public function send()
 {
     $config = $this->args[0];
     $message = $this->args[1];
     $email = new CakeEmail('resqueEmail');
     CakeLog::write(LOG_DEBUG, print_r($email->config(), true));
     CakeLog::write(LOG_DEBUG, print_r($config, true));
     $email->config($config);
     CakeLog::write(LOG_DEBUG, print_r($email->config(), true));
     $email->send($message);
 }
 /**
  * Sends out email via SendGrid
  *
  * @return bool
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     if (empty($this->_config['count']) || $this->_config['count'] > 500) {
         $this->_config['count'] = 500;
     }
     $this->_headers = $this->_cakeEmail->getHeaders();
     $this->_recipients = $email->to();
     $this->_replyTo = $email->replyTo();
     return $this->_sendPart();
 }
Example #8
0
 public function sendEmail($to, $subject, $template = 'default', $content = null, $viewVars = [], $options = [])
 {
     $defaults = ['emailFormat' => 'html'];
     $options = array_merge($defaults, $options);
     $email = new CakeEmail();
     $email->config('smtp');
     $email->config(['from' => ['*****@*****.**' => Configure::read('General.site_name')]]);
     $email->to($to);
     $email->setHeaders(['X-Mailer' => "Hurad Mail"]);
     $email->emailFormat($options['emailFormat']);
     $email->template($template);
     $email->viewVars($viewVars);
     $email->subject($subject);
     $email->send($content);
 }
Example #9
0
 public function main()
 {
     define('TIMEZONE', 'Asia/Bangkok');
     date_default_timezone_set(TIMEZONE);
     $now = date("Y-m-d H:i:s");
     $tomorrow = date("Y-m-d H:i:s", time() + EVENT_REMIDER_TIMER);
     $optionCalendar = array('order' => array('from_date' => 'asc'), 'conditions' => array('from_date >=' => $now, 'to_date <=' => $tomorrow));
     $events = $this->Calendar->find("all", $optionCalendar);
     foreach ($events as $key => $event) {
         $content = array();
         $content["id"] = $event["Calendar"]["id"];
         $content["name"] = $event["Calendar"]["name"];
         $content["description"] = $event["Calendar"]["description"];
         $content["from_date"] = $this->_formatDate($events[$key]["Calendar"]["from_date"], "d-m-Y H:i");
         $content["to_date"] = $this->_formatDate($events[$key]["Calendar"]["to_date"], "d-m-Y H:i");
         $id = $event["Calendar"]["id"];
         $user = $this->UserModel->findById($event["Calendar"]["user_id"]);
         $content["receive_name"] = $user["UserModel"]["display_name"];
         $Email = new CakeEmail('noreply');
         $noreplyConf = $Email->config();
         $Email->template('calendar_remider');
         $Email->emailFormat('html');
         $Email->viewVars(array('emailContent' => $content));
         $Email->from($noreplyConf['from']);
         $Email->to($user["UserModel"]["user_email"]);
         $Email->subject(__('Calendar Reminder'));
         $Email->send();
     }
     //echo EVENT_REMIDER_TIMER;
 }
 public function index()
 {
     if (!empty($this->data)) {
         if ($this->request->is('post')) {
             $data = $this->request->data;
             if ($this->Matriculation->save($data)) {
                 $email = new CakeEmail();
                 $email->config('default');
                 $email->from(array('*****@*****.**' => 'Sardonix Idiomas | Automático'));
                 $email->to('*****@*****.**');
                 $email->subject("Matrícula - {$data['Matriculation']['name']} ");
                 $cursos = '';
                 if (isset($data['Matriculation']['english'])) {
                     $cursos .= 'Inglês; ';
                 }
                 if (isset($data['Matriculation']['italian'])) {
                     $cursos .= 'Italiano; ';
                 }
                 if (isset($data['Matriculation']['portuguese'])) {
                     $cursos .= 'Português; ';
                 }
                 $date = new DateTime();
                 $message = "Nome: {$data['Matriculation']['name']}\n\n";
                 $message .= "Telefone: {$data['Matriculation']['phone']}\n\n";
                 $message .= "Celular: {$data['Matriculation']['cellphone']}\n\n";
                 $message .= "Idiomas de interesse: {$cursos}\n\n";
                 $message .= "E-mail: {$data['Matriculation']['email']} \n\n";
                 $message .= "Soube: {$data['Matriculation']['where']}\n\n";
                 $message .= "Acessou em: " . $date->format('d/m/Y H:i:s');
                 $email->send($message);
                 $this->render('enviado');
             }
         }
     }
 }
 public function handleException(Exception $exception, $shutdown = false)
 {
     $this->_exception = $exception;
     $email = new CakeEmail('error');
     $prefix = Configure::read('ExceptionNotifier.prefix');
     $from = $email->from();
     if (empty($from)) {
         $email->from('*****@*****.**', 'Exception Notifier');
     }
     $subject = $email->subject();
     if (empty($subject)) {
         $email->subject($prefix . '[' . date('Ymd H:i:s') . '][' . $this->_getSeverityAsString() . '][' . ExceptionText::getUrl() . '] ' . $exception->getMessage());
     }
     if ($this->useSmtp) {
         $email->transport('Smtp');
         $email->config($this->smtpParams);
     }
     $text = ExceptionText::getText($exception->getMessage(), $exception->getFile(), $exception->getLine());
     $email->send($text);
     // return Exception.handler
     if ($shutdown || !$this->_exception instanceof ErrorException) {
         $config = Configure::read('Exception');
         $handler = $config['handler'];
         if (is_string($handler)) {
             call_user_func($handler, $exception);
         } elseif (is_array($handler)) {
             call_user_func_array($handler, $exception);
         }
     }
 }
Example #12
0
 public function individualMail($section, $arr = array())
 {
     $this->autoRender = false;
     $contents = $this->Mail->findBySection($section);
     $content = $contents['Mail']['content'];
     foreach ($arr as $key => $val) {
         $content = str_replace("~~{$key}~~", $val, $content);
     }
     if (!empty($arr['TO_EMAIL']) && Validation::email($arr['TO_EMAIL'], true)) {
         $email = new CakeEmail();
         $email->template('default');
         $email->config('default');
         $email->emailFormat('html')->to($arr['TO_EMAIL'])->subject($contents['Mail']['subject']);
         try {
             if ($email->send($content)) {
                 return;
             } else {
                 return;
             }
         } catch (Exception $e) {
             return;
         }
     }
     return;
 }
Example #13
0
 public function process()
 {
     $c = new CakeEmail('default');
     //grab 50 emails
     $emails = $this->EmailMessage->find("all", array("conditions" => array("EmailMessage.processed" => 0, "EmailMessage.to !=" => '', "NOT" => array("EmailMessage.to" => null)), "contain" => array()));
     $total_emails = count($emails);
     $this->out("emails to processes: " . $total_emails);
     SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Emails to processes: " . $total_emails));
     foreach ($emails as $email) {
         $e = $email['EmailMessage'];
         $c->reset();
         $c->config('default');
         $c->to($e['to']);
         $c->subject($e['subject']);
         $c->template($e['template']);
         $c->viewVars(array("msg" => $email));
         if ($c->send()) {
             $this->EmailMessage->create();
             $this->EmailMessage->id = $e['id'];
             $this->EmailMessage->save(array("processed" => 1, "sent_date" => DboSource::expression('NOW()')));
             $total_emails--;
             $this->out("Email:" . $e['to'] . " Template: " . $e['template']);
         } else {
             $this->out("Email failed: " . $e['id']);
             SysMsg::add(array("category" => "Emailer", "from" => "MailerShell", "crontab" => 1, "title" => "Email Failed: " . $e['id']));
         }
     }
 }
Example #14
0
 public function sendEmail($to = NULL, $subject = NULL, $data = NULL, $template = NULL, $format = 'text', $cc = NULL, $bcc = NULL)
 {
     $Email = new CakeEmail();
     $Email->from(array(Configure::read('Email_From_Email') => Configure::read('Email_From_Name')));
     //$Email->config(Configure::read('TRANSPORT'));
     $Email->config('default');
     $Email->template($template);
     if ($to != NULL) {
         $Email->to($to);
     }
     if ($cc != NULL) {
         $Email->cc($cc);
     }
     if ($bcc != NULL) {
         $Email->bcc($bcc);
     }
     $Email->subject($subject);
     $Email->viewVars($data);
     $Email->emailFormat($format);
     if ($Email->send()) {
         return true;
     } else {
         return false;
     }
 }
Example #15
0
 /**
  * Wenn es sich um einen POST-Request handelt, wird eine Rundmail mit den übergebenen Daten versendet.
  * 
  * @author aloeser
  * @return void
  */
 public function index()
 {
     if ($this->request->is('POST')) {
         $conditions = array('User.mail !=' => '', 'User.admin != ' => 2);
         if (!$this->request->data['Mail']['sendToAll']) {
             $conditions['User.leave_date'] = null;
         }
         $activeUsersWithEmail = $this->User->find('all', array('conditions' => $conditions));
         $receivers = array();
         foreach ($activeUsersWithEmail as $user) {
             array_push($receivers, $user['User']['mail']);
         }
         $senderMail = '*****@*****.**';
         $senderName = 'Humboldt Cafeteria';
         $EMail = new CakeEmail();
         $EMail->from(array($senderMail => $senderName));
         $EMail->bcc($receivers);
         $EMail->subject($this->request->data['Mail']['subject']);
         $EMail->config('web');
         $EMail->template('default');
         $EMail->emailFormat('html');
         $EMail->viewVars(array('senderName' => $senderName, 'senderMail' => $senderMail, 'content' => $this->request->data['Mail']['content'], 'subject' => $this->request->data['Mail']['subject'], 'allowReply' => $this->request->data['Mail']['allowReply']));
         if ($EMail->send()) {
             $this->Session->setFlash('Die Rundmail wurde erfolgreich abgeschickt.', 'alert-box', array('class' => 'alert-success'));
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash('Beim Senden ist ein Fehler aufgetreten.', 'alert-box', array('class' => 'alert-error'));
         }
     }
     $this->set('actions', array());
 }
Example #16
0
 public function send()
 {
     if ($this->request->is('post')) {
         // Check security token
         if (empty($this->request->data['Feedback']['token']) || $this->request->data['Feedback']['token'] != '!pilule$') {
             throw new NotFoundException();
         }
         // Send feedback via email
         $Email = new CakeEmail();
         if (!empty($this->request->data['Feedback']['name']) && !empty($this->request->data['Feedback']['email'])) {
             $Email->replyTo(array($this->request->data['Feedback']['email'] => $this->request->data['Feedback']['name']));
         }
         $Email->from('*****@*****.**');
         $Email->to('*****@*****.**');
         $Email->config('postmark');
         $Email->subject('Pilule - Commentaires');
         $Email->template('feedback');
         $Email->emailFormat('html');
         $Email->viewVars(array('message' => $this->request->data));
         if ($Email->send()) {
             return new CakeResponse(array('body' => json_encode(array('status' => true))));
         } else {
             return new CakeResponse(array('body' => json_encode(array('status' => false))));
         }
     } elseif ($this->request->is('ajax')) {
         $this->layout = 'ajax';
         $this->render('modals/form');
     }
 }
Example #17
0
 public function sendEmail()
 {
     App::import('Model', 'Setting');
     $setting_model = new Setting();
     $setting = $setting_model->find('first', array('fields' => 'email_contact'));
     $email_contact = empty($setting['Setting']['email_contact']) ? '' : $setting['Setting']['email_contact'];
     if (!empty($this->data['Contato'])) {
         $contato = $this->data['Contato'];
         App::uses('CakeEmail', 'Network/Email');
         $Email = new CakeEmail();
         $Email->config('smtp');
         $Email->template('contato', null);
         $Email->viewVars(array('contato' => $contato));
         $Email->to($email_contact);
         $Email->emailFormat('html');
         $Email->subject("Cartório NET - Contato: " . $contato['subject']);
         $success = false;
         try {
             if ($Email->send()) {
                 $success = true;
             } else {
                 $success = false;
             }
         } catch (Exception $e) {
             //                pr($e);die;
             $success = false;
         }
         return $success;
     }
     return false;
 }
Example #18
0
 /**
  * Contact form for new users.  Creates a new User based on their form information.  User has a specific 
  * "new user" role and placeholders for username and password.  
  * @param bool $sent - indicates if the form is new or being loaded after information has been sent.
  * @return void
  */
 public function contact($sent = false)
 {
     if ($this->request->is('post')) {
         $this->loadModel('Role');
         $this->loadModel('User');
         //set the User up as a NEW USER
         $this->request->data['User']['role_id'] = Role::NEW_USER;
         //add a temp username and password
         $this->request->data['User']['username'] = User::TEMP_USERNAME;
         $this->request->data['User']['password'] = User::TEMP_PASSWORD;
         $this->User->create();
         if ($this->User->save($this->request->data)) {
             $Email = new CakeEmail();
             $Email->config('gmail');
             //TO-DO:: Figure out the proper configuration for using GreenGeeks webmail
             //$Email->config('unlessWeb');
             $Email->from(array($this->request->data['User']['email'] => $this->request->data['User']['first_name']));
             $Email->to('*****@*****.**');
             $Email->subject('Someone is interested in Evolved Foods....');
             $Email->replyTo($this->request->data['User']['email']);
             $Email->send($this->request->data['User']['message']);
             return $this->redirect(array('action' => 'contact', true));
         } else {
             $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
         }
     }
     $this->set('sent', $sent);
 }
 /**
  * メール送信処理
  */
 public function sendEmail($to, $subject, $template, $body = null)
 {
     // メールライブラリ読み込み
     App::uses('CakeEmail', 'Network/Email');
     $email = new CakeEmail();
     $res = $email->config(array('log' => 'emails'))->template($template, 'default')->viewVars($body)->from(array('*****@*****.**' => __('iPost Enterprise運営事務局')))->to($to)->subject($subject)->send();
 }
 /**
  * testPostmarkSend method
  *
  * @return void
  */
 public function testPostmarkSend()
 {
     $this->email->config('postmark');
     $this->email->template('default', 'default');
     $this->email->emailFormat('html');
     $this->email->from(array('*****@*****.**' => 'Your Name'));
     $this->email->to(array('*****@*****.**' => 'Recipient'));
     $this->email->cc(array('*****@*****.**' => 'Recipient'));
     $this->email->bcc(array('*****@*****.**' => 'Recipient'));
     $this->email->subject('Test Postmark');
     $this->email->addHeaders(array('Tag' => 'my tag'));
     $this->email->attachments(array('cake.icon.png' => array('file' => WWW_ROOT . 'img' . DS . 'cake.icon.png')));
     $sendReturn = $this->email->send();
     $headers = $this->email->getHeaders(array('to'));
     $this->assertEqual($sendReturn['To'], $headers['To']);
     $this->assertEqual($sendReturn['ErrorCode'], 0);
     $this->assertEqual($sendReturn['Message'], 'OK');
 }
Example #21
0
 public function recoverPassword($email, $user)
 {
     $fullName = $user['User']['name'] . ' ' . $user['User']['lastname'];
     $password = trim((string) User::randomPassword());
     $Email = new CakeEmail();
     $Email->config('smtp');
     $Email->from(array('*****@*****.**' => 'bvmjm'))->template('forgot', 'default')->viewVars(array('name' => $fullName, 'password' => $password))->emailFormat('html')->to($email)->subject('bvmjm, Recuperación de Contraseña de Administrador')->send();
     $this->data['User']['password'] = $password;
     $this->save();
 }
Example #22
0
 private function __sendPaymentSuccess($email_address, $email_data)
 {
     $from = Configure::read('RentSquare.supportemail');
     $email = new CakeEmail();
     $email->config('default');
     $email->domain('rentsquaredev.com');
     $email->sender('*****@*****.**', 'RentSquare Support');
     $email->template('monthlyfeesuccess', 'generic')->emailFormat('html')->from(array($from => 'RentSquare Support'))->to($email_address)->subject('RentSquare Payment Receipt')->viewVars(array('email_data' => $email_data))->send();
     return true;
 }
 public function main()
 {
     $email = new CakeEmail();
     $email->config(array('transport' => 'AmazonSESTransport.AmazonSES', 'log' => true, 'Amazon.SES.Key' => Configure::read('Amazon.SES.Key'), 'Amazon.SES.Secret' => Configure::read('Amazon.SES.Secret')));
     $email->sender('*****@*****.**');
     $email->from('*****@*****.**', 'Example');
     $email->to('*****@*****.**');
     $email->bcc('*****@*****.**');
     $email->subject('SES Test from CakePHP');
     $res = $email->send('test message.');
     var_dump($res);
 }
Example #24
0
 public function send($email)
 {
     $message = new CakeEmail();
     $message->config('smtp');
     $message->from(array('*****@*****.**' => 'Agile Leagues'));
     $message->to($email);
     $message->template($this->template);
     $message->emailFormat('html');
     $message->viewVars($this->viewVars);
     $message->subject($this->subject);
     $message->send();
 }
 public function send()
 {
     $Email = new CakeEmail();
     $Email->config('gmail');
     $Email->template('notification', 'default1');
     $Email->emailFormat('html');
     $Email->from(array('*****@*****.**' => 'Columbia English Libary'));
     $Email->to('*****@*****.**');
     $Email->subject('Columbia English Libary Notification');
     $Email->viewVars(array('user_name' => 'Leo', 'content_lines' => 'Test Cakephp Email!'));
     $Email->send();
 }
 /**
  * Sends out email via Mandrill
  *
  * @param $email
  * @return array Return the Mandrill
  */
 public function send(CakeEmail $email)
 {
     //todo:check restricted_emails
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders(array('from', 'to', 'cc', 'bcc', 'replyTo', 'subject'));
     // Setup connection
     $this->__mandrillConnection =& new HttpSocket();
     $message = $this->__buildMessage();
     $request = array('header' => array('Accept' => 'application/json', 'Content-Type' => 'application/json'));
     if ($this->_cakeEmail->template()['template']) {
         $message_send_uri = $this->_config['uri'] . "messages/send-template.json";
     } else {
         $message_send_uri = $this->_config['uri'] . "messages/send.json";
     }
     //perform the http connection
     $returnMandrill = $this->__mandrillConnection->post($message_send_uri, json_encode($message), $request);
     //parse mandrill results
     $result = json_decode($returnMandrill, true);
     $headers = $this->_headersToString($this->_headers);
     return array_merge(array('Mandrill' => $result), array('headers' => $headers, 'message' => $message));
 }
 /**
  * @param CakeEmail $email
  * @return array
  * @throws CakeException
  */
 public function send(CakeEmail $email)
 {
     // Setup connection
     $connection =& new HttpSocket();
     $config = $email->config();
     $this->data['apiKey'] = $config['api_key'];
     $this->data['test'] = $config['test'];
     $request = $this->buildRequest($email);
     // Send message
     $return = $connection->post($config['url'], http_build_query($request));
     // Return data
     $result = json_decode($return, true);
     return array('MailerLoop' => $result);
 }
Example #28
0
 public function send($id = null, $username = null)
 {
     $this->set('title_for_layout', SITE_NAME . ' &bull; Compose');
     if ($this->request->is('get')) {
         $this->Message->id = $id;
         if ($this->Message->exists() && $this->Message->isOwnedBy($id)) {
             $messageData = $this->Message->read();
             $this->set($this->request->data[$this->Message->alias]['title'] = $messageData['Message']['title']);
             $body = '';
             foreach (explode(PHP_EOL, $messageData['Message']['body']) as $line) {
                 $body .= '> ' . $line . PHP_EOL;
             }
             $body = str_repeat(PHP_EOL, 4) . '> **' . $messageData['From']['username'] . ' wrote at ' . $messageData[$this->Message->alias]['created'] . '**' . PHP_EOL . '> ' . PHP_EOL . trim($body);
             $this->set($this->request->data[$this->Message->alias]['body'] = $body);
         }
         $this->set($this->request->data[$this->Message->alias]['to'] = $username);
     }
     if ($this->request->is('post')) {
         // send to recipient
         $this->request->data[$this->Message->alias]['from_user_id'] = $this->Auth->User('id');
         $this->request->data[$this->Message->alias]['to_user_id'] = $this->Message->User->field('id', array('username' => $this->request->data[$this->Message->alias]['to']));
         $this->request->data[$this->Message->alias]['user_id'] = $this->Message->User->field('id', array('username' => $this->request->data[$this->Message->alias]['to']));
         $this->Message->create();
         if ($this->Message->save($this->request->data)) {
             // check if email notifications are enabled and send email to recipient
             $userId = $this->Message->User->field('id', array('username' => $this->request->data[$this->Message->alias]['to']));
             $this->Message->User->id = $userId;
             $userData = $this->Message->User->read();
             if ($userData['User']['message_alert'] == "1") {
                 $email = new CakeEmail();
                 $email->config('noreply');
                 $email->template('message_alert');
                 $email->viewVars(array('toUsername' => $userData['User']['username'], 'fromUsername' => $this->Auth->User('username')));
                 $email->to($userData['User']['email']);
                 $email->subject('New private message');
                 $email->emailFormat('html');
                 $email->send();
             }
             // send copy to sent messages
             $this->request->data[$this->Message->alias]['viewed'] = 0;
             $this->request->data[$this->Message->alias]['user_id'] = $this->Auth->User('id');
             $this->Message->create();
             if ($this->Message->save($this->request->data)) {
                 $this->Session->setFlash('Your message has been sent', 'default', array('class' => 'success'));
                 $this->redirect(array('controller' => 'messages', 'action' => 'index'));
             }
         }
     }
 }
Example #29
0
 /**
  * Sends out email via Postmark
  *
  * @return array Return the Postmark
  */
 public function send(CakeEmail $email)
 {
     // CakeEmail
     $this->_cakeEmail = $email;
     $this->_config = $this->_cakeEmail->config();
     $this->_headers = $this->_cakeEmail->getHeaders(array('from', 'to', 'cc', 'bcc', 'replyTo', 'subject'));
     // Setup connection
     $this->__postmarkConnection =& new HttpSocket();
     // Build message
     $message = $this->__buildMessage();
     // Build request
     $request = $this->__buildRequest();
     // Send message
     $returnPostmark = $this->__postmarkConnection->post($this->_config['uri'], json_encode($message), $request);
     // Return data
     $result = json_decode($returnPostmark, true);
     $headers = $this->_headersToString($this->_headers);
     if ($this->_cakeEmail->emailFormat() === 'html') {
         $message = $message['HtmlBody'];
     } else {
         $message = $message['TextBody'];
     }
     return array_merge(array('Postmark' => $result), array('headers' => $headers, 'message' => $message));
 }
Example #30
0
 /**
  * Send mail
  *
  * @param CakeEmail $email CakeEmail
  * @return array
  */
 public function send(CakeEmail $email)
 {
     if (!empty($this->_config['queue'])) {
         $this->_config = $this->_config['queue'] + $this->_config;
         $email->config((array) $this->_config['queue'] + ['queue' => []]);
         unset($this->_config['queue']);
     }
     $transport = $this->_config['transport'];
     $email->transport($transport);
     $QueuedTask = ClassRegistry::init('Queue.QueuedTask');
     $result = $QueuedTask->createJob('Email', ['transport' => $transport, 'settings' => $email]);
     $result['headers'] = '';
     $result['message'] = '';
     return $result;
 }