/**
  * 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);
 }
Ejemplo n.º 2
0
 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);
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * sendResetMail
  *
  */
 public static function sendResetMail($data, $user)
 {
     $modelName = $data['model'];
     $loader = ReminderConfigLoader::init($modelName);
     $email = new CakeEmail('reminder');
     $from = $email->from();
     if (empty($from)) {
         $email->from('*****@*****.**', 'Reminder');
     }
     $subject = $loader->load('subject');
     if (empty($subject)) {
         $subject = $email->subject();
     }
     if (empty($subject)) {
         $subject = 'Reminder';
         // default
     }
     $email->subject($subject);
     $email->to($data['email']);
     $template = $loader->load('view.reset_mail');
     if (empty($template)) {
         $template = 'reset_mail';
     }
     $email->template('Reminder.' . $template);
     $email->viewVars(array('data' => $data, 'user' => $user));
     return $email->send();
 }
 /**
  * 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()));
     }
 }
 /**
  * Prepares the data array.
  *
  * @return void 
  */
 protected function _prepareData()
 {
     $headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
     if ($headers['Sender'] == '') {
         $headers['Sender'] = $headers['From'];
     }
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", $this->_cakeEmail->message());
     $this->_data = array('Data' => base64_encode($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n."));
     $this->_dataOptions = array('Source' => key($this->_cakeEmail->from()), 'Destinations' => array());
     $this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->to());
     $this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->cc());
     $this->_dataOptions['Destinations'] += array_keys($this->_cakeEmail->bcc());
     $this->_content = array('headers' => $headers, 'message' => $message);
 }
Ejemplo n.º 6
0
 public function preview($e)
 {
     $configName = $e['EmailQueue']['config'];
     $template = $e['EmailQueue']['template'];
     $layout = $e['EmailQueue']['layout'];
     $headers = empty($e['EmailQueue']['headers']) ? array() : (array) $e['EmailQueue']['headers'];
     $theme = empty($e['EmailQueue']['theme']) ? null : (string) $e['EmailQueue']['theme'];
     if (empty($theme)) {
         $theme = '';
     }
     $email = new CakeEmail($configName);
     $email->transport('Debug')->to($e['EmailQueue']['to'])->subject($e['EmailQueue']['subject'])->template($template, $layout)->emailFormat($e['EmailQueue']['format'])->addHeaders($headers)->theme($theme)->messageId(false)->returnPath($email->from())->viewVars($e['EmailQueue']['template_vars']);
     $return = $email->send();
     $this->out('Content:');
     $this->hr();
     $this->out($return['message']);
     $this->hr();
     $this->out('Headers:');
     $this->hr();
     $this->out($return['headers']);
     $this->hr();
     $this->out('Data:');
     $this->hr();
     debug($e['EmailQueue']['template_vars']);
     $this->hr();
     $this->out();
 }
Ejemplo n.º 7
0
 /**
  * permet de refaire un mot de passe oublié
  * @return [type] [description]
  **/
 public function forgot()
 {
     $this->layout = "home";
     if (!empty($this->request->data)) {
         $user = $this->User->findByMail($this->request->data['User']['mail'], array('id'));
         if (empty($user)) {
             $this->Session->setFlash(__("This email address is not associated with any account"), 'notif', array('class' => "danger", 'type' => 'info'));
         } else {
             $token = md5(uniqid() . time());
             $this->User->id = $user['User']['id'];
             $this->User->saveField('token', $token);
             App::uses('CakeEmail', 'Network/Email');
             $cakeMail = new CakeEmail('smtp');
             // à changer par default sur le site en ligne ou smtp en local
             $cakeMail->to($this->request->data['User']['mail']);
             $cakeMail->from(array('*****@*****.**' => "site "));
             $cakeMail->subject(__('Password regeneration'));
             $cakeMail->template('forgot');
             $cakeMail->viewVars(array('token' => $token, 'id' => $user['User']['id']));
             $cakeMail->emailFormat('text');
             $cakeMail->send();
             $this->Session->setFlash(__("An email was sent to you with instructions to regenerate your password! Please check your span !!"), "notif", array('class' => 'info', 'type' => 'info'));
         }
     }
 }
 public function index()
 {
     //checking session
     $uid = $this->Session->read('Auth.User.id');
     if (isset($uid)) {
         return $this->redirect(array('controller' => 'profiles', 'action' => 'edit'));
     }
     $this->layout = 'main';
     $title = 'User Registration';
     $this->set(compact('title'));
     //check from submit or not
     if ($this->request->is('post')) {
         //uploading image file
         $new_file_name = rand(1000, rand(100000, rand(1000000, 10000000))) . "_" . md5(time()) . "_" . time() . $this->data['Profile']['image']['name'];
         move_uploaded_file($this->data['Profile']['image']['tmp_name'], $_SERVER['DOCUMENT_ROOT'] . '/registration/app/webroot/img/image/' . $new_file_name);
         $this->request->data['Profile']['image'] = '/registration/app/webroot/img/image/' . $new_file_name;
         //----------------------
         //save data
         if ($this->Profile->save($this->request->data)) {
             $Email = new CakeEmail();
             $Email->from(array('*****@*****.**' => 'Cake registration demo'));
             $Email->to($this->data['Profile']['email']);
             $Email->subject('Registration process completed successfully');
             $Email->send('Welcome to cake registration demo .Your registration process completed successfully');
             $this->Session->setFlash('User details has been saved.', 'default', array('class' => 'alert alert-success'));
             return $this->redirect(array('action' => 'login'));
         }
         //------------
         //on failure
         $this->Session->setFlash('Unable to add User details.', 'default', array('class' => 'alert alert-danger'));
     }
 }
Ejemplo n.º 9
0
 /**
  * Send comfirmation email whit unique code
  */
 public function send_mail()
 {
     $user = $this->Session->read('Auth');
     if (isset($user)) {
         if ($user['User']['active'] == 0) {
             $uniqueId = uniqid("", TRUE);
             if ($this->saveSendComfirmation($user, $uniqueId)) {
                 App::uses('CakeEmail', 'Network/Email');
                 $email = new CakeEmail('gmail');
                 $link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . "email/activate_account/" . $user['User']['id'] . '-' . $uniqueId;
                 $email->from('*****@*****.**');
                 $email->to($user['User']['email']);
                 $email->subject('Mail Confirmation');
                 $email->emailFormat('html');
                 $email->template('signup');
                 $email->viewVars(array('username' => $user['User']['full_name'], 'link' => $link));
                 $this->Session->setFlash(__('Email comfirmation has been sent'), 'flash/success');
                 $email->send();
             } else {
                 $this->Session->setFlash(__('Could not send email.'), 'flash/error');
             }
         } else {
             $this->Session->setFlash(__('Your email is already comfirmed.'), 'flash/error');
         }
     } else {
         $this->Session->setFlash(__('You are not login.'), 'flash/error');
     }
     $this->redirect('/');
 }
Ejemplo n.º 10
0
 /**
  * index method
  *
  * @return void
  */
 public function index()
 {
     $this->Comment->recursive = 0;
     if (!empty($this->request->data)) {
         $this->Comment->create($this->request->data);
         if ($this->Comment->validates()) {
             if (!empty($this->request->data['Comment']['website'])) {
                 $this->Session->setFlash(__("Your Mail us is reached."), 'notif', array('class' => "success", 'type' => 'ok-sign'));
                 $this->request->data = array();
             } else {
                 $token = md5(time() . ' - ' . uniqid());
                 $this->Comment->create(array('name' => $this->request->data['Comment']['name'], 'mail' => $this->request->data['Comment']['mail'], 'content' => $this->request->data['Comment']['content'], 'token' => $token));
                 $this->Comment->save();
                 App::uses('CakeEmail', 'Network/Email');
                 $CakeEmail = new CakeEmail('smtp');
                 // à changer par Default sur le site en ligne sinon smtp
                 $CakeEmail->to(array('*****@*****.**'));
                 $CakeEmail->from(array($this->request->data['Comment']["mail"] => "livre d or"));
                 $CakeEmail->subject(__("Commentaire sur le livre d'or"));
                 $CakeEmail->viewVars($this->request->data['Comment'] + array("name" => $this->Comment->name, "mail" => $this->Comment->mail, "content" => $this->Comment->content, 'token' => $token, 'id' => $this->Comment->id));
                 $CakeEmail->emailFormat('html');
                 $CakeEmail->template('commentaire');
                 $CakeEmail->send();
                 $this->Session->setFlash(__('The comment has been saved.'), 'notif', array('class' => "success", 'type' => 'ok-sign'));
                 return $this->redirect(array('action' => 'index'));
             }
         } else {
             $this->Session->setFlash(__('The comment could not be saved. Please, try again.'), 'notif', array('class' => "danger", 'type' => 'info-sign'));
         }
     }
     $this->paginate = array('Comment' => array('limit' => 3, 'order' => array('Comment.created' => 'desc')));
     $d['comments'] = $this->Paginate('Comment', array('Comment.online >= 1'));
     $this->set($d);
 }
 protected function __resetPassword($username = '')
 {
     $this->loadModel('User');
     $conditions = array('username' => $username);
     $options = array('conditions' => $conditions);
     $user = $this->User->find('first', $options);
     $message = 'El usuario no existe.';
     if ($user) {
         $data['password'] = $this->strongPassword($username);
         $this->User->id = $user['User']['id'];
         $mensaje = 'No ha sido posible cambiar el password, intente de nuevo.';
         if ($this->User->save($data)) {
             $email = new CakeEmail('default');
             $email->template('change_password');
             $email->emailFormat('text');
             $email->from('*****@*****.**');
             $email->to($username);
             $email->subject('Reinicio de credenciales gobscore.');
             $email->viewVars(array('username' => $username, 'password' => $data['password']));
             $message = 'El password ha sido cambiado con éxito. Ha ocurrido un ' . 'error en el envío de su nuevo password.';
             if ($email->send()) {
                 $message = 'Los datos de la institución y cuenta de ' . 'administrador han sido enviados correctamente';
             }
         }
     }
     return $message;
 }
Ejemplo n.º 12
0
 /**
  * add method
  *
  * @return void
  */
 public function add()
 {
     $institucions = $this->User->Institucion->find('list');
     if ($this->request->is('post')) {
         // Password
         $password = $this->strongPassword($this->request->data['User']['username']);
         $this->request->data['User']['password'] = $password;
         $this->request->data['User']['role'] = 'administrador';
         $this->request->data['User']['active'] = true;
         $this->User->create();
         if ($this->User->save($this->request->data)) {
             // Envio de clave al usuario
             $email = new CakeEmail('default');
             $email->template('administrador');
             $email->emailFormat('text');
             $email->from('*****@*****.**');
             $email->to($this->request->data['User']['username']);
             $email->subject('Cuenta gobscore.');
             $email->viewVars(array('name' => $this->request->data['User']['name'], 'institucion' => $institucions[$this->request->data['User']['institucion_id']], 'username' => $this->request->data['User']['username'], 'password' => $password));
             if ($email->send()) {
                 $mensaje = 'Los datos de la institución y cuenta de ' . 'administrador han sido enviados correctamente';
             }
             $this->Session->setFlash($mensaje);
             return $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(__('La información ha no sido almacenada. Por favor, trate de nuevo.'));
         }
     }
     $this->set(compact('institucions'));
 }
 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 contact()
 {
     $this->loadModel('Contact');
     if ($this->request->is('post')) {
         $this->Contact->set($this->request->data);
         if ($this->Contact->validates()) {
             App::uses('CakeEmail', 'Network/Email');
             if ($this->request->data['Contact']['subject'] == '') {
                 $this->request->data['Contact']['subject'] = 'Contact';
             }
             $Email = new CakeEmail('smtp');
             $Email->viewVars(array('mailData' => $this->request->data));
             $Email->template('contact', 'default');
             $Email->emailFormat('html');
             $Email->from(array($this->request->data['Contact']['mail'] => $this->request->data['Contact']['name']));
             $Email->to('*****@*****.**');
             $Email->subject($this->request->data['Contact']['subject']);
             $Email->attachments(array('logo.png' => array('file' => WWW_ROOT . '/img/icons/logo.png', 'mimetype' => 'image/png', 'contentId' => 'logo')));
             $Email->send();
             $this->Flash->success(__('Votre mail a bien été envoyé.'));
             return $this->redirect($this->referer());
         } else {
             $this->Session->write('errors.Contact', $this->Contact->validationErrors);
             $this->Session->write('data', $this->request->data);
             $this->Session->write('flash', 'Le mail n’a pas pu être envoyé. Veuillez réessayer SVP.');
             return $this->redirect($this->referer());
         }
     }
 }
Ejemplo n.º 15
0
 function RecoverPassword($username)
 {
     $response = array('status' => false, 'message' => 'Ocurrió un error');
     $this->Behaviors->attach('Containable');
     if ($user = $this->find('first', array('conditions' => array('UsuarioInterno.username' => $username), 'contain' => array('Empresa')))) {
         $this->id = $user['UsuarioInterno']['id'];
         $token = md5($user['UsuarioInterno']['id'] . $user['UsuarioInterno']['username'] . date('d-m-Y'));
         if ($this->saveField('token', $token)) {
             App::uses('CakeEmail', 'Network/Email');
             $url = Router::url(array('controller' => 'empresas', 'action' => 'cambiar_clave', $token), true);
             $Email = new CakeEmail();
             $Email->template('password');
             $Email->from(array('*****@*****.**' => 'Xperiencia Laboral'));
             $Email->to($user['UsuarioInterno']['email']);
             $Email->subject('Recuperacion contraseña Xperiencia Laboral');
             $Email->viewVars(array('nombre' => $user['UsuarioInterno']['nombre'] . ' ' . $user['UsuarioInterno']['apellido'], 'url' => $url));
             $Email->emailFormat('html');
             if ($Email->send()) {
                 $response['message'] = 'Un link para reestablecer tu contraseña ha sido enviado a tu email ' . $user['UsuarioInterno']['email'];
                 $response['status'] = true;
             } else {
                 $response['message'] = 'Ocurrio un error al intentar enviar el mail';
             }
         }
     } else {
         $response['message'] = 'El email ingresado no corresponde a un usuario existente';
     }
     return $response;
 }
Ejemplo n.º 16
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;
     }
 }
Ejemplo n.º 17
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());
 }
Ejemplo n.º 18
0
 public function add()
 {
     //新規会員登録
     if ($this->request->is('post')) {
         $this->User->set($this->data);
         if ($this->User->validates()) {
             // status => 0, regist_code => xxxxxxxxxxxxxxx を $this->data に入れる
             $uuid = md5(uniqid());
             $data = $this->data;
             $data['User']['regist_code'] = $uuid;
             $this->User->save($data);
             $email = new CakeEmail('gmail');
             // インスタンス化
             $email->from(array('*****@*****.**' => 'Sender'));
             // 送信元
             $email->to('*****@*****.**');
             // 送信先
             $email->subject('twitter課題テスト');
             // メールタイトル
             $email->emailFormat('html');
             // フォーマット
             $email->template('mailsendtest');
             // テンプレートファイル
             $email->viewVars(array('registurl' => 'http://dev.elites.com/elites/twitter/users/registcomplete/', 'regist_code' => $uuid));
             $email->send('');
             // メール送信
             $this->redirect(array('contoller' => 'users', 'action' => 'sendmailcomplete'));
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Saves a lead into the leads table
  * @param  array  $data
  * @param  string $type The lead type - usually the page type
  * @return boolean
  */
 public function saveLead($data = array(), $type = null)
 {
     if (!$data || !$type) {
         throw new NotFoundException(__('Invalid data or type'));
     }
     $data['Lead']['type'] = $type;
     $this->create();
     $result = $this->save($data);
     if (!$result) {
         throw new LogicException(__('There was a problem, please review the errors below and try again.'));
     }
     $this->Setting = ClassRegistry::init('Setting');
     $siteEmail = $this->Setting->get('siteEmail');
     $siteName = $this->Setting->get('siteName');
     $ccEmails = $this->Setting->get('siteEmailsCc');
     if ($siteEmail) {
         App::uses('CakeEmail', 'Network/Email');
         $email = new CakeEmail();
         $email->from(array($result['Lead']['email'] => $result['Lead']['name']));
         $email->to($siteEmail);
         if ($ccEmails) {
             $email->cc($ccEmails);
         }
         $email->subject(__('%s - The %s form has been submitted', $siteName, $result['Lead']['type']));
         $email->template('newLead');
         $email->emailFormat('both');
         $email->viewVars(array('lead' => $result, 'siteName' => $siteName));
         $email->send();
     }
     return true;
 }
Ejemplo n.º 20
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;
 }
Ejemplo n.º 21
0
 /**
  * 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);
 }
Ejemplo n.º 22
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');
     }
 }
Ejemplo n.º 23
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);
 }
 /**
  * Prepares the `from` email address.
  *
  * @return array
  */
 protected function _prepareFromAddress()
 {
     $from = $this->_cakeEmail->returnPath();
     if (empty($from)) {
         $from = $this->_cakeEmail->from();
     }
     return $from;
 }
Ejemplo n.º 25
0
 public function sendEmail($to, $from)
 {
     App::uses('CakeEmail', 'Network/Email');
     $Email = new CakeEmail('dynamic');
     $msg = "Hey,\nI downloaded this cool Digi Stickers App and I thought you would be interested in downloading it too.\nCheck it out! <a href='https://play.google.com/store/apps/details?id=com.tdb.tbdapp.&hl=en'>Click Here</a>\n";
     $sub = "Your Friend invited you!!";
     // $Email->sender('*****@*****.**', 'Your Company Support');
     $Email->from(array('*****@*****.**' => 'Digi Stickers'))->viewVars(array('subject' => $sub, 'content', $msg))->emailFormat('html')->template('emailInvite', 'emailInvite')->replyTo($from)->to($to)->subject($sub)->send($msg);
 }
Ejemplo n.º 26
0
 /**
  * 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');
 }
Ejemplo n.º 27
0
 /**
  * add method
  *
  * @return void
  */
 public function email($id)
 {
     App::uses('CakeEmail', 'Network/Email');
     $Email = new CakeEmail();
     $name1 = $this->QualityReport->findById($id);
     $Email->from(array('*****@*****.**' => '*****@*****.**'))->to($name1['QualityReport']['to'])->subject($name1['QualityReport']['subject'])->send($name1['QualityReport']['content']);
     $this->Session->setFlash(__('Email has been sent'));
     return $this->redirect(array('action' => 'index'));
 }
 public function sendEmail($toEmail, $subject, $message)
 {
     $Email = new CakeEmail('default');
     $Email->from(array('*****@*****.**' => 'Administrator'));
     $Email->to($toEmail);
     $Email->subject($subject);
     $Email->send($message);
     var_dump(debug($Email->smtpError));
 }
Ejemplo n.º 29
0
 private function send_mail($recipient = null, $username = null, $id = null, $password = null)
 {
     $link = array('controller' => 'users', 'action' => 'activate', $id . '-' . md5($password));
     App::uses('CakeEmail', 'Network/Email');
     $email = new CakeEmail('gmail');
     $email->from('*****@*****.**')->to($recipient)->subject('Mail Confirmation');
     $email->emailFormat('html')->template('activation')->viewVars(array('username' => $username, 'link' => $link));
     $email->send();
 }
Ejemplo n.º 30
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();
 }