public function notificarAction() { //Conectamos a BBDD $sid = new Container('base'); $db_name = $sid->offsetGet('dbNombre'); $remitente = "Comit�"; $this->dbAdapter = $this->getServiceLocator()->get($db_name); //Obtenemos datos POST $post = $this->request->getPost(); if (isset($post['destino'])) { //Validamos si es mensaje directo a Dpto if (isset($post['dpto'])) { //Consultamos datos del dpto $dptoMail = new UnidadTable($this->dbAdapter); $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']); $htmlMarkup = \HtmlCorreo::htmlMensajeDirecto($lista[0]['nombre'], $remitente, $post['textbody']); $html = new MimePart($htmlMarkup); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html)); $message = new Message(); $message->addTo($lista[0]['correo'])->addFrom('*****@*****.**', 'Notificacion becheck')->setSubject($post['asunto'])->setBody($body); $transport = new SendmailTransport(); $transport->send($message); //Retornamos a la vista $result = new JsonModel(array('status' => 'ok', 'descripcion' => 'Se ha enviado correctamente un correo')); //$result->setTerminal(true); return $result; } $result = new JsonModel(array('status' => 'ok', 'descripcion' => $post)); $result->setTerminal(true); return $result; } //Instancias $dpto = new UnidadTable($this->dbAdapter); $form = new NotificacionForm("form"); //Obtenemos combo dptos $dptos = $dpto->getDatosActivos(); //Cargamos dptos en formulario $form->get('id_unidad')->setAttribute('options', $dptos); $this->layout('layout/comite'); return new ViewModel(array('form' => $form)); }
public function enviarAction() { //Obtenemos datos POST $post = $this->request->getPost(); //Conectamos a BBDD $sid = new Container('base'); $remitente = "Conserje"; $db_name = $sid->offsetGet('dbNombre'); $this->dbAdapter = $this->getServiceLocator()->get($db_name); //Tablas $dptoMail = new UnidadTable($this->dbAdapter); //Validamos destinatario if (isset($post['dpto'])) { //Consultamos datos del dpto $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']); } else { //Consultamos datos del dpto $lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']); } //Armamos EMAIL $htmlMarkup = \HtmlCorreo::htmlMensajeDirecto($lista[0]['nombre'], $remitente, $post['textbody']); $html = new MimePart($htmlMarkup); $html->type = "text/html"; $body = new MimeMessage(); $body->setParts(array($html)); $message = new Message(); $message->addTo($lista[0]['correo'])->addFrom('*****@*****.**', 'Notificación becheck')->setSubject($post['asunto'])->setBody($body); $transport = new SmtpTransport(); $options = new SmtpOptions(array('name' => 'smtp.gmail.com', 'host' => 'smtp.gmail.com', 'port' => '587', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'xofita123', 'ssl' => 'tls'))); $transport->setOptions($options); $transport->send($message); //Retornamos a la vista $result = new JsonModel(array('status' => 'ok', 'descripcion' => 'Se ha enviado correctamente un correo')); //$result->setTerminal(true); return $result; }