Example #1
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $this->form = new MessageForm();
     $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
     if ($this->form->isValid()) {
         $message = $this->form->save();
         $data['message'] = $message->message;
         $data['email_address'] = $message->email_address;
         //--------------------------------------------------------------------------
         // build message
         //--------------------------------------------------------------------------
         $email = new esEmailMessage('Solicitud de Contacto ATC');
         $email->setAutoEmbedImages(true);
         $email->setBodyFromTemplate($this->getController(), 'contact', 'contact_request', $data, 'none');
         //--------------------------------------------------------------------------
         // send to client
         //--------------------------------------------------------------------------
         $email->setFrom($message->email_address);
         $email->setTo(sfConfig::get('app_email_contact'));
         $this->getMailer()->send($email);
         $this->redirect('contact/confirmation');
     }
     $this->setTemplate('index');
 }
 /**
  * handles the sending of notification related to reservation events
  *
  * @param string $template name of the template to be used for the email
  * @param array $data parameters required to build the messfga
  * @return
  */
 protected static function sendNotification($template, $data)
 {
     $email_addr = $data['email_address'];
     unset($data['email_address']);
     $mailer = sfContext::getInstance()->getMailer();
     $controller = sfContext::getInstance()->getController();
     //--------------------------------------------------------------------------
     // build message
     //--------------------------------------------------------------------------
     $message = new esEmailMessage($data['subject']);
     $message->setAutoEmbedImages(true);
     $message->setBodyFromTemplate($controller, 'reservation', $template, $data, 'email_layout');
     //--------------------------------------------------------------------------
     // send to client
     //--------------------------------------------------------------------------
     $message->setFrom(sfConfig::get('app_email_from'));
     $message->setTo($email_addr);
     $mailer->send($message);
     //--------------------------------------------------------------------------
     // send to backend
     //--------------------------------------------------------------------------
     $message->setFrom(sfConfig::get('app_email_from'));
     $message->setTo(sfConfig::get('app_email_bcc'));
     $mailer->send($message);
 }
Example #3
0
 public function executeViewEmail(sfWebRequest $request)
 {
     sfConfig::set('sf_web_debug', false);
     $this->setLayout(false);
     $reservation_id = $request->getParameter('id');
     $template = $request->getParameter('template');
     $type = $request->getParameter('type');
     $reservation = Doctrine::getTable('Reservation')->find($reservation_id);
     //	  $url = sprintf('http://%s/access/%s',
     //  	  sfConfig::get('app_domain_name', $_SERVER['SERVER_NAME']),
     //  	  Encryption::encodeUrl('reservation', 'access', array(
     //  	    'user_id' => $reservation->Client->User->id,
     //  	    'uniqid'  => $reservation->uniqid
     //  	  ))
     //	  );
     $url = sprintf('http://%s/access/%s', sfConfig::get('app_domain_name', $_SERVER['SERVER_NAME']), Encryption::getEncryptedUrlFromUri('@reservation_show?uniqid=' . $reservation->uniqid, $reservation->Client->User->id));
     $data['reservation'] = $reservation;
     $data['url'] = $url;
     $data['subject'] = 'Subject';
     $filename = $template . '_' . $type;
     $message = new esEmailMessage('Test Email');
     $message->setFrom(sfConfig::get('app_email_from'));
     $message->setTo('*****@*****.**');
     $message->setAutoEmbedImages(false);
     $message->setBodyFromTemplate($this->getController(), 'reservation', $filename, $data, $type == 'html' ? 'email_layout' : 'none');
     return $this->renderText($message->getBody());
 }