function execute(JitFilter $data) { require_once 'lib/mail/maillib.php'; try { $mail = tiki_get_admin_mail(); if ($replyto = $data->replyto->email()) { $mail->setReplyTo($replyto); } foreach ($data->to->email() as $to) { $mail->addTo($this->stripNp($to)); } foreach ($data->cc->email() as $cc) { $mail->addCc($this->stripNp($cc)); } foreach ($data->bcc->email() as $bcc) { $mail->addBcc($this->stripNp($bcc)); } $content = $this->parse($data->content->none()); $subject = $this->parse($data->subject->text()); $mail->setSubject(strip_tags($subject)); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($content); $bodyMessage->type = \Zend\Mime\Mime::TYPE_HTML; $bodyPart->setParts(array($bodyMessage)); $mail->setBody($bodyPart); tiki_send_email($mail); return true; } catch (Exception $e) { return false; } }
/** * Creates a new user * @param \Zend\Db\Adapter\Adapter $db * @param type $login * @param type $password * @return \login\user\User */ public static function createLoginInstance(\Zend\Db\Adapter\Adapter $db, $login, $password) { $user = self::getLoginInstance($db, $login); if (is_object($user) && $user->getData('username') != '') { throw new \Exception('Username already used ' . $login, 1409011238); } $adminColl = new \login\user\LoginColl($db); $adminColl->loadAll(array('role_id' => 3)); $role_id = 3; $role_description = 'User'; $active = 0; if ($adminColl->count() == 0) { $role_id = 1; $role_description = 'Administrator'; $active = 1; } $profileRole = new \login\user\ProfileRole($db); $profileRole->loadFromId($role_id); if ($profileRole->getData('id') != $role_id) { $defaultRuleFile = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . 'profile_role.sql'; if (is_file($defaultRuleFile)) { $db->query(file_get_contents($defaultRuleFile), \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE); } $profileRole->loadFromId($role_id); if ($profileRole->getData('id') != $role_id) { $profileRole->setData(array('id' => $role_id, 'description' => $role_description)); $profileRole->insert(); } } $user = new \login\user\Login($db); $user->setData(array('username' => $login, 'password' => md5($password), 'creation_datetime' => date('Y-m-d H:i:s'), 'confirm_code' => md5(serialize($_SERVER) . time()))); $user->insert(); $profile = $user->getProfile(); $profile->setData(array('role_id' => $role_id, 'active' => $active)); $profile->update(); ob_start(); require $db->baseDir . DIRECTORY_SEPARATOR . 'mail' . DIRECTORY_SEPARATOR . 'register.php'; $html = new \Zend\Mime\Part(ob_get_clean()); $html->type = 'text/html'; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message = new \Zend\Mail\Message(); $message->addTo($login)->addFrom($GLOBALS['config']->mail_from)->setSubject('Registrazione sul sito ' . $GLOBALS['config']->siteName)->setBody($body); $GLOBALS['transport']->send($message); if ($adminColl->count() > 0) { ob_start(); require $db->baseDir . DIRECTORY_SEPARATOR . 'mail' . DIRECTORY_SEPARATOR . 'new_user.php'; $html = new \Zend\Mime\Part(ob_get_clean()); $html->type = 'text/html'; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message = new \Zend\Mail\Message(); foreach ($adminColl->getItems() as $admin) { $message->addTo($admin->getData('username')); } $message->addFrom($GLOBALS['config']->mail_from)->setSubject('Registrazione sul sito ' . $GLOBALS['config']->siteName)->setBody($body); $GLOBALS['transport']->send($message); } return $user; }
public function send($subject, $messageBody) { $html = new \Zend\Mime\Part(nl2br($messageBody)); $html->type = 'text/html'; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message = new Message(); $message->addFrom($this->fromAddress, $this->fromName)->addTo($this->toAddress)->setSubject($subject); $message->setBody($body); $transport = $this->getTransport(); $transport->send($message); }
function send($to, $subject, $html, $ical = null) { $message = new Message(); $message->addTo($to)->addFrom('*****@*****.**')->setSubject($subject); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($html); $bodyMessage->type = 'text/html'; $parts = array($bodyMessage); if ($ical) { $icalMessage = new \Zend\Mime\Part($ical); $icalMessage->type = 'text/calendar'; $parts = array_merge($parts, array($icalMessage)); } $bodyPart->setParts($parts); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); $this->transport->send($message); }
public function send($subject, $messageBody) { if (empty($subject)) { throw new \InvalidArgumentException("subject may not be empty"); } $subject = sprintf("[%s] %s", substr(strtoupper(\Whathood\Util::environment()), 0, 4), $subject); $html = new \Zend\Mime\Part(nl2br($messageBody)); $html->type = 'text/html'; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message = new Message(); $message->addFrom($this->fromAddress, $this->fromName)->addTo($this->toAddress)->setSubject($subject); $message->setBody($body); $transport = $this->getTransport(); if (\Whathood\Util::is_production()) { $transport->send($message); } }
public function sendMail($email, $fullname, $linkActive) { $message = new \Zend\Mail\Message(); $smtpOption = new SmtpOptions($this->_config); $message->setFrom($this->_config['connectionConfig']['username'], "bookStoreOnline"); $message->setTo($email, $fullname); $message->setSubject("Kích hoạt tài khoản"); $message->setEncoding("utf-8"); //set HTML $content = new \Zend\Mime\Part("<p>Xin chào " . $fullname . "</p> \n\t\t\t<p>Bạn vừa đăng ký tài khoản tại website BookOnline,\n\t\t\tđể hoàn thành việc đăng ký bạn cui lòng <a href='" . $linkActive . "'>Click vào đây</a>\n\t\t\tđể kích hoạt tài khoản</p>"); $content->type = Mime::TYPE_HTML; $content->charset = "utf-8"; $mimeMessage = new \Zend\Mime\Message(); $mimeMessage->setParts(array($content)); $message->setBody($mimeMessage); $transport = new \Zend\Mail\Transport\Smtp($smtpOption); $transport->send($message); }
/** * @param string $subject * @param string $plain * @param string $html * @param string $messageId * * @return \Zend\Mail\Message */ public function createMessage($subject, $plain, $html, $messageId) { $mail = $this->getMessageClass(); $mail->setFrom(\Yii::$app->params['mailFromEmail'], \Yii::$app->params['mailFromName']); $mail->setSubject($subject); $mail->setEncoding('UTF-8'); $mId = new \Zend\Mail\Header\MessageId(); $mId->setId($messageId); $mail->getHeaders()->addHeader($mId); if ($html == '') { $mail->setBody($plain); $content = new \Zend\Mail\Header\ContentType(); $content->setType('text/plain'); $content->addParameter('charset', 'UTF-8'); $mail->getHeaders()->addHeader($content); } else { $html = '<!DOCTYPE html><html> <head><meta charset="utf-8"><title>' . Html::encode($subject) . '</title> </head><body>' . $html . '</body></html>'; $converter = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($html); $converter->setStripOriginalStyleTags(true); $converter->setUseInlineStylesBlock(true); $converter->setEncoding('UTF-8'); $converter->setCleanup(false); $converter->setExcludeMediaQueries(true); $contentHtml = $converter->convert(); $contentHtml = preg_replace("/ data\\-[a-z0-9_-]+=\"[^\"]*\"/siu", "", $contentHtml); $textPart = new \Zend\Mime\Part($plain); $textPart->type = 'text/plain'; $textPart->charset = 'UTF-8'; $htmlPart = new \Zend\Mime\Part($contentHtml); $htmlPart->type = 'text/html'; $htmlPart->charset = 'UTF-8'; $mimem = new \Zend\Mime\Message(); $mimem->setParts([$textPart, $htmlPart]); $mail->setBody($mimem); /** @var ContentType $contentType */ $contentType = $mail->getHeaders()->get('content-type'); $contentType->setType('multipart/alternative'); } return $mail; }
/** * @param string $queue_name * @param string $to * @param string $subject * @param string $body * @param null $from * @param true $html */ public function addMail($queue_name, $to, $subject, $body, $from = null, $html = false) { $message = new \Zend\Mail\Message(); $message->setTo($to); $message->setSubject($this->translate ? $this->translate->translate($subject) : $subject); if ($html) { $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($body); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message->setBody($bodyPart); } else { $message->setBody($body); } $message->setEncoding("UTF-8"); if ($from) { $message->setFrom($from); } else { $message->setFrom($this->config['default_from']); } $this->table->add($queue_name, $message); }
/** * @see \BoilerAppMessenger\Message\MessageTransporterInterface::sendMessage() * @param \BoilerAppMessenger\Message\Message $oMessage * @throws \UnexpectedValueException * @return \BoilerAppMessenger\Media\Mail\MailMessageTransporter */ public function sendMessage(\BoilerAppMessenger\Message\Message $oMessage) { //Adapt message $oAdaptedMessage = new \Zend\Mail\Message(); $oAdaptedMessage->setEncoding('UTF-8'); //From Sender $oFrom = $oMessage->getFrom(); if ($oFrom instanceof \BoilerAppMessenger\Media\Mail\MailMessageUserInterface) { $oAdaptedMessage->setFrom($oFrom->getUserEmail(), $oFrom->getUserDisplayName()); } else { throw new \UnexpectedValueException(sprintf('"From" sender expects an instance of \\BoilerAppMessenger\\Mail\\MailMessageUserInterface, "%s" given', is_scalar($oFrom) ? $oFrom : (is_object($oFrom) ? get_class($oFrom) : gettype($oFrom)))); } //To Recipiants foreach ($oMessage->getTo() as $oTo) { if ($oTo instanceof \BoilerAppMessenger\Media\Mail\MailMessageUserInterface) { $oAdaptedMessage->addTo($oTo->getUserEmail(), $oTo->getUserDisplayName()); } else { throw new \UnexpectedValueException(sprintf('"To" Recipiant expects an instance of \\BoilerAppMessenger\\Mail\\MailMessageUserInterface, "%s" given', is_scalar($oTo) ? $oTo : (is_object($oTo) ? get_class($oTo) : gettype($oTo)))); } } //Subject $oAdaptedMessage->setSubject($oMessage->getSubject()); //Reset attachments $this->attachments = array(); foreach ($oMessage->getAttachments() as $sAttachmentFilePath) { $this->addFileAttachment($sAttachmentFilePath); } //Body $oBodyPart = new \Zend\Mime\Part(preg_replace_callback('/src="([^"]+)"/', array($this, 'processImageSrc'), $this->getMessageRenderer()->renderMessageBody($oMessage))); $oBodyPart->type = \Zend\Mime\Mime::TYPE_HTML; $oBody = new \Zend\Mime\Message(); $oBody->setParts(array_merge(array($oBodyPart), $this->attachments)); $oAdaptedMessage->setBody($oBody)->setEncoding('UTF-8'); //Send message $this->getMailTransporter()->send($oAdaptedMessage); return $this; }
public function sendEmailsFromQueue($developmentMode = false) { $transport = $this->serviceManager->get('SlmMail\\Mail\\Transport\\SesTransport'); $entity = new $this->config['database']['entity'](); $tableName = $this->entityManager->getClassMetadata(get_class($entity))->getTableName(); $dql = 'SELECT m FROM ' . $this->config['database']['entity'] . ' m WHERE m.send = 0 AND m.scheduleDate <= :now ORDER BY m.prio, m.createDate DESC'; $query = $this->entityManager->createQuery($dql)->setParameter('now', date('Y-m-d H:i:s'))->setMaxResults($this->config['numberOfEmailsPerRun']); $queue = $query->getResult(); foreach ($queue as $mail) { // In development mode we only send emails to predefined email addresses to prevent "strange" unrequested // emails to users. if ($developmentMode === true && !in_array($mail->getRecipientEmail(), $this->config['developmentEmails'])) { $this->entityManager->getConnection()->update($tableName, array('send' => 1), array('id' => $mail->getId())); continue; } $message = new \Zend\Mail\Message(); $message->addFrom($mail->getSenderEmail(), $mail->getSenderName())->addTo($mail->getRecipientEmail(), $mail->getRecipientName())->setSubject($mail->getSubject()); if (trim($mail->getBodyHTML()) !== '') { $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($mail->getBodyHTML()); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); } else { $message->setBody($mail->getBodyText()); } try { $transport->send($message); $this->entityManager->getConnection()->update($tableName, array('send' => 1, 'sendDate' => date('Y-m-d H:i:s')), array('id' => $mail->getId())); } catch (\Exception $e) { $this->entityManager->getConnection()->update($tableName, array('send' => 2, 'error' => $e->getMessage()), array('id' => $mail->getId())); $this->queueNewMessage('MailAdmin', $this->config['adminEmail'], $e->getMessage(), $e->getMessage(), 'MailQueue Error', 9); } } }
/** * Send an event by email to the corresponding IPO */ public function sendEventAction() { $id = $this->params()->fromQuery('id', 0); $messages = array(); if ($id) { $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $eventservice = $this->getServiceLocator()->get('EventService'); $customfieldservice = $this->getServiceLocator()->get('CustomFieldService'); $event = $objectManager->getRepository('Application\\Entity\\Event')->find($id); $formatter = \IntlDateFormatter::create(\Locale::getDefault(), \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, 'UTC', \IntlDateFormatter::GREGORIAN, 'dd LLL, HH:mm'); if ($event) { $content = 'Nom : ' . $eventservice->getName($event) . '<br />'; $content .= 'Début : ' . $formatter->format($event->getStartdate()) . '<br />'; $content .= 'Fin : ' . ($event->getEnddate() ? $formatter->format($event->getEnddate()) : 'Inconnu') . '<br />'; foreach ($event->getCustomFieldsValues() as $value) { $content .= $value->getCustomField()->getName() . ' : ' . $customfieldservice->getFormattedValue($value->getCustomField(), $value->getValue()) . '<br />'; } $text = new \Zend\Mime\Part($content); $text->type = \Zend\Mime\Mime::TYPE_HTML; $text->charset = 'utf-8'; $mimeMessage = new \Zend\Mime\Message(); $mimeMessage->setParts(array($text)); $config = $this->serviceLocator->get('config'); if (!$config['emailfrom'] || !$config['smtp']) { $messages['error'][] = "Envoi d'email non configuré, contactez votre administrateur."; } else { $message = new \Zend\Mail\Message(); $message->addTo($event->getOrganisation()->getIpoEmail())->addFrom($config['emailfrom'])->setSubject("Envoi d'un évènement par le CDS : " . $eventservice->getName($event))->setBody($mimeMessage); $transport = new \Zend\Mail\Transport\Smtp(); $transportOptions = new \Zend\Mail\Transport\SmtpOptions($config['smtp']); $transport->setOptions($transportOptions); try { $transport->send($message); $messages['success'][] = "Evènement correctement envoyé à " . $event->getOrganisation()->getIpoEmail(); } catch (\Exception $e) { $messages['error'][] = $e->getMessage(); } } } else { $messages['error'][] = "Envoi d'email impossible : évènement non trouvé."; } } else { $messages['error'][] = "Envoi d'email impossible : évènement non trouvé."; } $json = array(); $json['messages'] = $messages; return new JsonModel($json); }
public function contactenosAction() { $view = new ViewModel(); $comidas = $this->joinAction()->toArray(); $storage = new \Zend\Authentication\Storage\Session('Auth'); $session = $storage->read(); if (!isset($session)) { $face = new \Usuario\Controller\ClientesController(); $facebook = $face->facebook(); $this->layout()->loginUrl = $facebook['loginUrl']; $this->layout()->user = $facebook['user']; if ($facebook['id_facebook']) { $url = '/contactenos'; $id_face = $this->getClientesTable()->usuarioface($facebook['email']); if (count($id_face) > 0) { if ($id_face[0]['id_facebook'] == '') { $this->getClientesTable()->idfacebook($id_face[0]['in_id'], $facebook['id_facebook'], $facebook['logoutUrl']); AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url); } else { $this->getClientesTable()->idfacebook2($id_face[0]['in_id'], $facebook['logoutUrl']); AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url); } } else { $this->getClientesTable()->insertarusuariofacebbok($facebook['name'], $facebook['email'], $facebook['id_facebook'], $facebook['logoutUrl']); AuthController::sessionfacebook($facebook['email'], $facebook['id_facebook'], $url); } } } $this->layout()->comidas = $comidas; $this->layout()->clase = 'Solicita'; $form = new Contactenos("form"); $request = $this->getRequest(); if ($request->isPost()) { $datos = array(); $datos['nombre'] = htmlspecialchars($this->params()->fromPost('nombre', 0)); $datos['email'] = htmlspecialchars($this->params()->fromPost('email', 0)); $datos['asunto'] = htmlspecialchars($this->params()->fromPost('asunto', 0)); $datos['mensaje'] = htmlspecialchars($this->params()->fromPost('mensaje', 0)); // $form->setInputFilter(new \Application\Form\ContactenosFiltro()); $form->setData($datos); if ($form->isValid()) { $bodyHtml = '<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> </head> <body> <div style="color: #7D7D7D"><br /> Nombre <strong style="color:#133088; font-weight: bold;">' . utf8_decode($datos['nombre']) . '</strong><br /> Email <strong style="color:#133088; font-weight: bold;">' . utf8_decode($datos['email']) . '</strong><br /> Asunto <strong style="color:#133088; font-weight: bold;">' . utf8_decode($datos['asunto']) . '</strong><br /> Mensaje <strong style="color:#133088; font-weight: bold;">' . utf8_decode($datos['mensaje']) . '</strong><br /> </div> </body> </html>'; $message = new Message(); $config = $this->getServiceLocator()->get('Config'); $message->addTo($config['mail']['transport']['options']['connection_config']['username'], $datos['nombre'])->setFrom($config['mail']['transport']['options']['connection_config']['username'], 'listadelsabor.com')->setSubject('Contactos de ListaDelSabor.com'); // ->setBody($bodyHtml); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($bodyHtml); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); $transport = $this->getServiceLocator()->get('mail.transport'); // new SendmailTransport(); $transport->send($message); $this->flashMessenger()->addMessage('Su mensaje ha sido enviado...'); $this->redirect()->toUrl($this->getRequest()->getBaseUrl() . '/contactenos'); // $this->redirect()->toUrl('/contactenos');///application/index } } $flashMessenger = $this->flashMessenger(); if ($flashMessenger->hasMessages()) { $mensajes = $flashMessenger->getMessages(); } $view->setVariables(array('form' => $form, 'mensaje' => $mensajes)); return $view; }
public function correo($correo, $usuario, $valor) { $message = new Message(); $message->addTo($correo, $usuario)->setFrom('*****@*****.**', 'listadelsabor.com')->setSubject('Confirmación de Registro en Listadelsabor.com'); $bodyHtml = '<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> </head> <body> <div style="color: #7D7D7D"><br /> Hola <strong style="color:#133088; font-weight: bold;">' . $usuario . ',</strong><br /><br /> Tu cuenta en <a href="' . self::$rutaStatic3 . '">listadelsabor.com</a> está casi lista para usar.<br /><br /> Activa tu cuenta haciendo <a href="' . self::$rutaStatic3 . '/auth?token=' . $valor . ' ">"click aqui"</a> <br /><br /> O copia la siguiente dirección en tu navegador:<br /><br /> <a href="' . self::$rutaStatic3 . '/?token=' . $valor . ' ">' . self::$rutaStatic3 . '/?token=' . $valor . '</a> <br /><br /><br /> <a href="' . self::$rutaStatic3 . '"><img src="' . self::$rutaStatic2 . '/logo.png" title="listadelsabor.pe"/></a> </div> </body> </html>'; $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($bodyHtml); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); $transport = $this->getServiceLocator()->get('mail.transport'); $transport->send($message); }
public static function send_email_zend($email, $betreff, $text_plain, $text_html = null, $mail_tag = null) { $mail = new Zend\Mail\Message(); $mail->setFrom(Yii::app()->params["adminEmail"], Yii::app()->params["adminEmailName"]); $mail->addTo($email, $email); $mail->setSubject($betreff); $mail->setEncoding("UTF-8"); if ($text_html !== null) { $converter = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($text_html); $converter->setStripOriginalStyleTags(false); $converter->setUseInlineStylesBlock(true); $converter->setEncoding("UTF-8"); $converter->setExcludeMediaQueries(true); $converter->setCleanup(false); $text_html = $converter->convert(); $text_part = new Zend\Mime\Part($text_plain); $text_part->type = "text/plain"; $text_part->charset = "UTF-8"; $html_part = new Zend\Mime\Part($text_html); $html_part->type = "text/html"; $html_part->charset = "UTF-8"; $mimem = new Zend\Mime\Message(); $mimem->setParts([$text_part, $html_part]); $mail->setBody($mimem); $mail->getHeaders()->get('content-type')->setType('multipart/alternative'); } else { $mail->setBody($text_plain); $headers = $mail->getHeaders(); $headers->removeHeader('Content-Type'); $headers->addHeaderLine('Content-Type', 'text/plain; charset=UTF-8'); } $transport = new Zend\Mail\Transport\Sendmail(); $transport->send($mail); }
/** * Create a email based on it's theme an params * * @param string $address * @param string $name * @throws Exception * @return \Zend\Mail\Message */ protected function _constructEmail($address, $name) { $content = $this->_template->render(); if ('' == $this->_replyTo) { $this->_replyTo = $this->_template->getTestament()->getReplyTo(); } if ('' == $this->_fromName) { $this->_fromName = $this->_template->getTestament()->getFromName(); } if ('' == $this->_fromAddress) { $this->_fromAddress = $this->_template->getTestament()->getFromAddress(); } if ('' == $this->_subject) { $this->_subject = $this->_template->getTestament()->getFromAddress(); } $contentParts = array(); $partText = new Part($content->getText()); $partText->encoding = Mime::ENCODING_QUOTEDPRINTABLE; $partText->type = Mime::TYPE_TEXT; $contentParts[] = $partText; $partHtml = new Part($content->getHtml()); $partHtml->encoding = Mime::ENCODING_QUOTEDPRINTABLE; $partHtml->type = Mime::TYPE_HTML; $partHtml->charset = 'UTF-8'; $contentParts[] = $partHtml; $alternatives = new \Zend\Mime\Message(); $alternatives->setParts($contentParts); $alternativesPart = new Part($alternatives->generateMessage()); $alternativesPart->type = "multipart/alternative; boundary=\"" . $alternatives->getMime()->boundary() . "\""; $body = new \Zend\Mime\Message(); $body->addPart($alternativesPart); foreach ($this->_attachments as $attachmentSrc) { $attachment = new Part(fopen($attachmentSrc['filelocation'], 'r')); $attachment->filename = $attachmentSrc['filename']; $attachment->encoding = Mime::ENCODING_BASE64; $attachment->type = Mime::DISPOSITION_ATTACHMENT; $attachment->disposition = true; $body->addPart($attachment); } $subject = $this->_subject; foreach ($this->_variables as $name => $variable) { $subject = str_replace('{{:' . $name . ':}}', $variable, $subject); } $message = new Message(); $message->setSubject($subject); $message->setFrom($this->_fromAddress, $this->_fromName); if ($this->_replyTo) { $message->setReplyTo($this->_replyTo); } $message->setBody($body); $message->setTo($address, $name); $message->setEncoding("UTF-8"); return $message; }
/** * Sets the new login * @param string $newLogin */ public function setNewLogin($newLogin) { $this->data['new_username'] = $newLogin; $this->data['confirm_code'] = md5(serialize($_SERVER) . time()); $this->update(); ob_start(); require $this->db->baseDir . DIRECTORY_SEPARATOR . 'mail' . DIRECTORY_SEPARATOR . 'changelogin.php'; $html = new \Zend\Mime\Part(ob_get_clean()); $html->type = 'text/html'; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message = new \Zend\Mail\Message(); $message->addTo($this->data['username'])->addFrom($GLOBALS['config']->mail_from)->setSubject('Conferma modifica email/username per accedere al sito ' . $GLOBALS['config']->siteName)->setBody($body); $GLOBALS['transport']->send($message); }
public function sendErrorEmail($textError) { $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); //TODO récupérer proprement l'organisation concernée $org = $objectManager->getRepository('Application\\Entity\\Organisation')->findAll(); $ipoEmail = $org[0]->getIpoEmail(); // prepare body with file attachment $text = new \Zend\Mime\Part($textError); $text->type = \Zend\Mime\Mime::TYPE_TEXT; $text->charset = 'utf-8'; $mimeMessage = new \Zend\Mime\Message(); $mimeMessage->setParts(array($text)); $config = $this->getServiceLocator()->get('config'); $message = new \Zend\Mail\Message(); $message->addTo($ipoEmail)->addFrom($config['emailfrom'])->setSubject("Erreur lors de l'import de l'AUP via NM B2B")->setBody($mimeMessage); $transport = new \Zend\Mail\Transport\Smtp(); $transportOptions = new \Zend\Mail\Transport\SmtpOptions($config['smtp']); $transport->setOptions($transportOptions); $transport->send($message); }
/** * Creates a mail message container of the given type for the mime parts. * * @param Zend\Mime\Part[] $parts List of mime parts that should be included in the container * @param string $type Mime type, e.g. "multipart/related" or "multipart/alternative" * @return \Zend\Mime\Part Container mime object */ protected function createContainer(array $parts, $type) { $msg = new \Zend\Mime\Message(); $msg->setParts($parts); $part = new \Zend\Mime\Part($msg->generateMessage()); $part->encoding = \Zend\Mime\Mime::ENCODING_8BIT; $part->boundary = $msg->getMime()->boundary(); $part->disposition = null; $part->charset = null; $part->type = $type; return $part; }
public function forgotpassAction() { $this->layout('layout/lazadatheme'); $this->productcart(); if ($this->request->isPost()) { $email = addslashes(trim($this->params()->fromPost('email'))); $check = $this->getAcountTable()->checkacount($email); if ($check) { $error = '<div class="alert alert-warning" role="alert">Email này không tồn tại</div>'; return array('error' => $error); } else { $Uty = new Utility(); $pass = $Uty->rand_string(8); $endpass = substr(base64_encode(md5($pass)), 0, -1); $data = array('password' => $endpass); $obj = new Customer(); $obj->exchangeArray($data); $this->getAcountTable()->updatepass($email, $obj); $message = array(); $message[] = ""; $message[] = "------ Yêu Cầu Thay Đổi Mật Khẩu -------"; $message[] = "Mật khảu hiện tại của bạn là : " . $pass; $message[] = ""; $message[] = "Hãy đăng nhập và thay đổi mật khẩu."; $message[] = ""; $message[] = "---------------------------------"; $textPart = new \Zend\Mime\Part(implode("\r\n", $message)); $textPart->type = "text/plain"; $body = new \Zend\Mime\Message(); $body->setParts(array($textPart)); $sendmail = new Message(); $sendmail->setTo($email); $sendmail->setFrom("*****@*****.**"); $sendmail->setEncoding("UTF-8"); $sendmail->setSubject("Yêu Cầu Thay Đổi Mật Khẩu."); $sendmail->setBody($body); $transport = new SmtpTransport(); $option = new SmtpOptions(array('name' => 'localhost', 'host' => '212.129.40.198', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => '+1*KR!y@-mn}'), 'port' => 25)); $transport->setOptions($option); $transport->send($sendmail); $error = '<div class="alert alert-success" role="alert">Một mật khẩu mới đã được gửi đén Email của bạn.</div>'; return array('error' => $error); } } }
public function lostPasswordAction() { $viewModel = new ViewModel(); $form = new LostPasswordForm(); $accountFilter = new AccountFIlter(); $filter = new InputFilter(); $filter->add($accountFilter->get('email')); $form->setInputFilter($filter); $request = $this->getRequest(); if ($request->isPost()) { $data = $request->getPost(); $form->setData($data); if ($form->isValid()) { $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); // 找到使用者 if ($user = $em->getRepository('Base\\Entity\\User')->findOneBy(array('email' => $form->get('email')->getValue()))) { $md5 = md5(time() . $user->getUserName() . $user->getEmail()); $user->setCheckCode($md5); $em->persist($user); $em->flush(); $view = new \Zend\View\Renderer\PhpRenderer(); $resolver = new \Zend\View\Resolver\TemplateMapResolver(); $resolver->setMap(array('mailLayout' => __DIR__ . '/../../../../Application/view/layout/layout-mail.phtml', 'mailTemplate' => __DIR__ . '/../../../view/user/sign/lost-password-mail.phtml')); $view->setResolver($resolver); $uri = $this->getRequest()->getUri(); $scheme = $uri->getScheme(); $host = $uri->getHost(); $base = sprintf('%s://%s%s', $scheme, $host, $this->getRequest()->getBasePath()); $viewModel->setTemplate('mailTemplate')->setVariables(array('user' => $user, 'url' => $base)); $content = $view->render($viewModel); $viewLayout = new ViewModel(); $viewLayout->setTemplate('mailLayout')->setVariables(array('content' => $content)); $body = $view->render($viewLayout); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($body); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message = new Mail\Message(); $message->addTo($user->getEmail(), $user->getusername()); $message->setFrom('*****@*****.**', '系統通知信'); $message->setSubject('重設密碼通知信'); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); $transport = new Mail\Transport\Sendmail(); $transport->send($message); // $viewModel->setTemplate('user/login/send-mail.phtml'); $this->flashmessenger()->addMessage($user->getEmail()); return $this->redirect()->toRoute('user/default', array('controller' => 'sign', 'action' => 'send-mail')); // return $viewModel; } else { $this->flashmessenger()->addMessage('您輸入了錯誤的帳號或電子郵件'); } } } $viewModel->setVariable('form', $form); $viewModel->setVariable('flashMessages', $this->flashMessenger()->getMessages()); return $viewModel; }
function setHtml($html, $text = null, $images_dir = null) { $body = $this->mail->getBody(); if (!$body instanceof \Zend\Mime\Message && !empty($body)) { $this->convertBodyToMime($body); $body = $this->mail->getBody(); } if (!$body instanceof Zend\Mime\Message) { $body = new Zend\Mime\Message(); } $partHtmlFound = false; $partTextFound = false; $parts = $body->getParts(); foreach ($parts as $part) { /* @var $part Zend\Mime\Part */ if ($part->getType() == Zend\Mime\Mime::TYPE_HTML) { $partHtmlFound = true; $part->setContent($html); } if ($part->getType() == Zend\Mime\Mime::TYPE_TEXT) { $partTextFound = true; if ($text) { $part->setContent($text); } } } if (!$partHtmlFound) { $htmlPart = new Zend\Mime\Part($html); $htmlPart->setType(Zend\Mime\Mime::TYPE_HTML); $parts[] = $htmlPart; } if (!$partTextFound && $text) { $textPart = new Zend\Mime\Part($text); $textPart->setType(Zend\Mime\Mime::TYPE_TEXT); $parts[] = $textPart; } $body->setParts($parts); $this->mail->setBody($body); }
public function reportAction() { $request = $this->getRequest(); if (!$request instanceof ConsoleRequest) { throw new \RuntimeException('Action only available from console.'); } $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $j = $request->getParam('delta'); $email = $request->getParam('email'); $org = $request->getParam('orgshortname'); $organisation = $objectManager->getRepository('Application\\Entity\\Organisation')->findBy(array('shortname' => $org)); if (!$organisation) { throw new \RuntimeException('Unable to find organisation.'); } else { $email = $organisation[0]->getIpoEmail(); if (empty($email)) { throw new \RuntimeException('Unable to find IPO email.'); } } $day = new \DateTime('now'); if ($j) { if ($j > 0) { $day->add(new \DateInterval('P' . $j . 'D')); } else { $j = -$j; $interval = new \DateInterval('P' . $j . 'D'); $interval->invert = 1; $day->add($interval); } } $day = $day->format(DATE_RFC2822); $criteria = Criteria::create()->where(Criteria::expr()->isNull('parent'))->andWhere(Criteria::expr()->eq('system', false))->orderBy(array('place' => Criteria::ASC)); $cats = $objectManager->getRepository('Application\\Entity\\Category')->matching($criteria); $eventsByCats = array(); foreach ($cats as $cat) { $category = array(); $category['name'] = $cat->getName(); $category['events'] = $objectManager->getRepository('Application\\Entity\\Event')->getEvents(null, $day, null, true, array($cat->getId())); $category['childs'] = array(); foreach ($cat->getChildren() as $subcat) { $subcategory = array(); $subcategory['events'] = $objectManager->getRepository('Application\\Entity\\Event')->getEvents(null, $day, null, true, array($subcat->getId())); $subcategory['name'] = $subcat->getName(); $category['childs'][] = $subcategory; } $eventsByCats[] = $category; } $pdf = new PdfModel(); $pdf->setOption('paperSize', 'a4'); $formatter = \IntlDateFormatter::create(\Locale::getDefault(), \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, 'UTC', \IntlDateFormatter::GREGORIAN, 'dd_LL_yyyy'); $pdf->setOption('filename', 'rapport_du_' . $formatter->format(new \DateTime($day))); $pdfView = new ViewModel($pdf); $pdfView->setTerminal(true)->setTemplate('application/report/daily')->setVariables(array('events' => $eventsByCats, 'day' => $day)); $html = $this->getServiceLocator()->get('viewpdfrenderer')->getHtmlRenderer()->render($pdfView); $engine = $this->getServiceLocator()->get('viewpdfrenderer')->getEngine(); $engine->load_html($html); $engine->render(); // creating directory if it doesn't exists if (!is_dir('data/reports')) { mkdir('data/reports'); } file_put_contents('data/reports/rapport_du_' . $formatter->format(new \DateTime($day)) . '.pdf', $engine->output()); if ($email) { // prepare body with file attachment $text = new \Zend\Mime\Part('Veuillez trouver ci-joint le rapport automatique de la journée du ' . $formatter->format(new \DateTime($day))); $text->type = \Zend\Mime\Mime::TYPE_TEXT; $text->charset = 'utf-8'; $fileContents = fopen('data/reports/rapport_du_' . $formatter->format(new \DateTime($day)) . '.pdf', 'r'); $attachment = new \Zend\Mime\Part($fileContents); $attachment->type = 'application/pdf'; $attachment->filename = 'rapport_du_' . $formatter->format(new \DateTime($day)) . '.pdf'; $attachment->disposition = \Zend\Mime\Mime::DISPOSITION_ATTACHMENT; $attachment->encoding = \Zend\Mime\Mime::ENCODING_BASE64; $mimeMessage = new \Zend\Mime\Message(); $mimeMessage->setParts(array($text, $attachment)); $config = $this->serviceLocator->get('config'); $message = new \Zend\Mail\Message(); $message->addTo($organisation[0]->getIpoEmail())->addFrom($config['emailfrom'])->setSubject('Rapport automatique du ' . $formatter->format(new \DateTime($day)))->setBody($mimeMessage); $transport = new \Zend\Mail\Transport\Smtp(); $transportOptions = new \Zend\Mail\Transport\SmtpOptions($config['smtp']); $transport->setOptions($transportOptions); $transport->send($message); } }
public function changeemailAction() { $view = new ViewModel(); $this->layout('layout/layout-portada2'); $request = $this->getRequest(); $form = new PasswordForm(); if ($request->isPost()) { $form->setData($request->getPost()); if ($form->isValid()) { $mail = $this->params()->fromPost('va_email'); try { $results = $this->getClientesTable()->generarPassword($mail); $usuario = $this->getClientesTable()->getUsuarioxEmail($mail); // $mensajes='Este correo fue enviado con exito...'; $this->flashmessenger()->addMessage('Se le ha enviado un correo a la cuenta indicada, por favor seguir las instrucciones.'); } catch (\Exception $e) { // $mensajes='Este correo no esta registrado...'; $this->flashmessenger()->addMessage('Este correo no esta registrado.'); } if ($results) { $config = $this->getServiceLocator()->get('Config'); $bodyHtml = '<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> </head> <body> <div style="color: #7D7D7D"><br /> Hola ' . ucwords($usuario->va_nombre_cliente) . ',<br /><br /> Para recuperar tu contraseña debes hacer <a href="' . $config['host']['base'] . '/?value=' . utf8_decode($results) . '">Clic Aquí</a><br /><br /> o copiar la siguiente url en su navegador:<br /><br />' . $config['host']['base'] . '/?value=' . utf8_decode($results) . ' </div> <br /><br /><br /> <img src="' . $config['host']['img'] . '/img/logo.png" title="listadelsabor.com"/> </body> </html>'; $message = new Message(); $message->addTo($mail)->addFrom('*****@*****.**', 'listadelsabor.com')->setSubject('Recuperación de contraseña'); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($bodyHtml); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); $transport = $this->getServiceLocator()->get('mail.transport'); // new SendmailTransport();//$this->getServiceLocator('mail.transport') $transport->send($message); } return $this->redirect()->toUrl('/cambio'); } else { foreach ($form->getInputFilter()->getInvalidInput() as $error) { $mensajes = $error->getMessages(); return new JsonModel(array('menssage' => $mensajes, 'success' => false)); exit; } } } $flashMessenger = $this->flashMessenger(); if ($flashMessenger->hasMessages()) { $mensajes = $flashMessenger->getMessages(); return new JsonModel(array('menssage' => $mensajes, 'success' => false)); exit; } return array('form' => $form, 'mensaje' => $mensajes); return $view; }
/** * @description creates a recover form and processes said form. * @return ViewModel */ public function recoverAction() { if ($this->authService->hasIdentity()) { return $this->redirect()->toRoute($this->config['onLoginRedirectRouteName']); } $request = $this->getRequest(); if ($request->isPost()) { $this->recoverForm->setInputFilter($this->recoverFormValidator->getInputFilter()); $this->recoverForm->setData($request->getPost()); if ($this->recoverForm->isValid()) { $recoverFormData = $this->recoverForm->getData(); $identityProperty = $this->authService->getAdapter()->getOptions()->getIdentityProperty(); $roleProperty = $this->config['acl']['roleProperty']; $userObject = $this->userService->setPasswordReset($recoverFormData['identity'], $identityProperty); if ($userObject) { $getter = 'get' . ucfirst($this->config['userEmailAddressProperty']); if (method_exists($userObject, $getter)) { $emailAddress = $userObject->{$getter}(); } elseif (property_exists($userObject, $roleProperty)) { $emailAddress = $userObject->{$identityProperty}; } else { throw new \UnexpectedValueException(sprintf('Property (%s) in (%s) is not accessible. You should implement %s::%s()', $identityProperty, get_class($userObject), get_class($userObject), $getter)); } $emailView = new ViewModel(); $emailView->setTemplate($this->config['viewPath']['emailTemplate'])->setVariables(array('user' => $userObject, 'identityProperty' => $identityProperty, 'identityValue' => $recoverFormData['identity'], 'email' => $emailAddress, 'config' => $this->config)); $emailContent = $this->viewRenderer->render($emailView); if (!empty($this->config['viewPath']['emailLayout'])) { $viewLayout = new \Zend\View\Model\ViewModel(); $viewLayout->setTemplate($this->config['viewPath']['emailLayout'])->setVariables(array('content' => $emailContent)); $emailContent = $this->viewRenderer->render($viewLayout); } $html = new Part($emailContent); $html->type = "text/html"; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message = new Message(); $message->setSubject($this->translator->translate($this->config['messages']['passwordResetEmailSubject'])); $fromEmail = isset($this->mailConfig['defaultFrom']) ? $this->mailConfig['defaultFrom'] : $this->mailTransport->getOptions()->getConnectionConfig()['username']; $message->addFrom($fromEmail); $message->addTo($emailAddress); $message->setBody($body); $this->mailTransport->send($message); } } $successMessage = $this->translator->translate($this->config['messages']['recoverSubmitSuccess']); if ($request->isXmlHttpRequest()) { $jsonResponse = new JsonModel(array('code' => 'recover-success', 'message' => $successMessage, 'success' => true)); return $jsonResponse; } else { $this->flashMessenger()->addSuccessMessage($successMessage); return $this->redirect()->toRoute('recover'); } } $viewModel = new ViewModel(array('form' => $this->recoverForm)); if (empty($this->config['layoutName'])) { $viewModel->setTerminal(true); } else { $this->layout($this->config['layoutName']); } $viewModel->setTemplate($this->config['viewPath']['recover']); //'storefront/index/recover.phtml' return $viewModel; }
public function forgotpasswordAction() { $this->layout('layout/bags'); $getuser = $this->getuserAction(); //var_dump($getuser); $this->layout()->getuser = $getuser; if ($this->request->isPost()) { $email = addslashes(trim($this->params()->fromPost('email'))); $check = $this->getAdminTable()->checkemail($email); if ($check == 1) { $pass = $this->getAdminTable()->generateRandomString(); $bcrypt = new Bcrypt(); $endpass = $bcrypt->create($pass); $this->getAdminTable()->forgotpass($email, $endpass); $message = array(); $message[] = ""; $message[] = "------ Thông tin mật khẩu-------"; $message[] = "Mật khảu hiện tại của bạn là : " . $pass; $message[] = ""; $message[] = "Hãy đăng nhập và thay đổi mật khẩu."; $message[] = ""; $message[] = WEBPATH . "/loginmaster"; $message[] = "---------------------------------"; $textPart = new \Zend\Mime\Part(implode("\r\n", $message)); $textPart->type = "text/plain"; $body = new \Zend\Mime\Message(); $body->setParts(array($textPart)); $sendmail = new Message(); $sendmail->setTo($email); $sendmail->setFrom("*****@*****.**"); $sendmail->setEncoding("UTF-8"); $sendmail->setSubject("Yêu Cầu Thay Đổi Mật Khẩu Tại ." . WEBPATH); $sendmail->setBody($body); $transport = new SmtpTransport(); $option = new SmtpOptions(array('name' => 'localhost', 'host' => '166.62.28.97', 'port' => '25', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'esell@Ellacy1990', 'ssl' => 'tls'))); $transport->setOptions($option); $transport->send($sendmail); $alert = '<p class="alert alert-success">A new password has been sent to e-mail us your check for information email accounts committee .</p>'; return array('alert' => $alert); } else { $alert = '<p class="alert alert-warning">This email is not registered</p>'; return array('alert' => $alert); } } }
/** * @param string $trackerString * @return \Zend\Mail\Message */ public function parse($trackerString = null) { //IF BODY // if the body is not empty, the we can // parse it through DOMDocument if (!empty($this->textBody)) { //MIME-MESSAGE // first we need mime-message, that will // hold all the parts (attachments) $mimeMessage = new \Zend\Mime\Message(); //IMAGES // then we convert the body string to DOMDocument // object and extract all images from it $domDocument = new \DOMDocument('1.0', 'UTF-8'); @$domDocument->loadHTML('<?xml encoding="utf-8" ?>' . $this->textBody); $images = $domDocument->getElementsByTagName('img'); $parts = array(); //LOOP IMAGES // then for every image we find in body text, we extract // the src, check it that is a real file and if so, convert // it into a Part object which we add to the mime-message foreach ($images as $image) { /** @var $image \DOMElement */ $realName = $image->getAttribute('src'); $cleanName = $this->cleanName(preg_replace('/^.+[\\\\\\/]/', '', $realName)); $templateImage = !$image->hasAttribute('template'); if (!$image->hasAttribute('template')) { $image->setAttribute('align', 'left'); $image->setAttribute('style', 'margin:0 10px 0 0;width:100%;max-width:100%'); } if (is_file(getcwd() . '/public' . $realName)) { //MIME // first for the MIME of the image $finfo = new \finfo(); $mime = $finfo->file(getcwd() . '/public' . $realName, FILEINFO_MIME_TYPE); $mime = $mime ? $mime : 'application/octet-stream'; //CID // the src attribute has to be changed to something simpler // and something that begins with 'cid:' then the ID of the // attachment gets the same value, that is how the html body // can reference an attachment as an image $image->setAttribute('src', 'cid:' . $cleanName); $fileContent = fopen(getcwd() . '/public' . $realName, 'r'); $attachment = new Part($fileContent); $attachment->type = $mime; $attachment->id = $cleanName; $attachment->filename = $cleanName; //$attachment->disposition = Mime::DISPOSITION_ATTACHMENT; $attachment->disposition = Mime::DISPOSITION_INLINE; // Setting the encoding is recommended for binary data $attachment->encoding = Mime::ENCODING_BASE64; //$mimeMessage->addPart( $attachment ); $parts[] = $attachment; } } //TRACKER IMAGE // if there is a tracker string passed, // we will set that as the SRC attribute of an IMG // element, this is done to try to track if a user opens // his/her mail. if ($trackerString) { $trackerImage = $domDocument->createElement('img'); /** @var $trackerImage \DOMElement */ $trackerImage->setAttribute('src', $trackerString); $trackerImage->setAttribute('height', 1); $trackerImage->setAttribute('width', 1); $domDocument->getElementsByTagName('body')->item(0)->appendChild($trackerImage); } //TEXT // one part of the mime-message is the actual body-text // which we treat like an attachment, that is: we create // a part and attache it to them mime-message $text = new Part(preg_replace('/^<!DOCTYPE.+?>/', '', str_replace(array('<html>', '</html>', '<body>', '</body>', '<?xml encoding="utf-8" ?>'), array('', '', '', '', ''), $domDocument->saveHTML()))); $text->type = Mime::TYPE_HTML; $text->charset = 'utf-8'; //$mimeMessage->addPart( $text ); $parts = array_merge(array($text), $parts); $mimeMessage->setParts($parts); $this->message->setBody($mimeMessage); } return $this->message; }
public function sendemailAction() { $data = $this->params()->fromQuery(); if (!isset($data['email']) || !$data['email']) { return 'Dữ liệu không đúng'; } if (!isset($data['activeKey']) || !$data['activeKey']) { return 'Dữ liệu không đúng'; } $validator = new \Zend\Validator\EmailAddress(); if ($validator->isValid($data['email'])) { $user = new User(); $user->setEmail($data['email']); $user->setActiveKey($data['activeKey']); /* @var $userMapper \User\Model\UserMapper */ $userMapper = $this->getServiceLocator()->get('User\\Model\\UserMapper'); if ($userMapper->checkExistsUserActive($user)) { $renderer = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface'); // Email content $viewContent = new \Zend\View\Model\ViewModel(array('activeLink' => Uri::buildAutoHttp('/user/user/activeaccount', ['u' => $user->getEmail(), 'c' => $user->getActiveKey()]))); $viewContent->setTemplate('email/activeFill'); // set in module.config.php $content = $renderer->render($viewContent); // Email layout $viewLayout = new \Zend\View\Model\ViewModel(array('content' => $content)); $viewLayout->setTemplate('email/layout'); // set in module.config.php $message = new Message(); $message->addTo($data['email']); $message->addFrom('*****@*****.**', $_SERVER['HTTP_HOST']); $message->setSubject('Welcome to ' . $_SERVER['HTTP_HOST']); $html = new \Zend\Mime\Part($renderer->render($viewLayout)); $html->type = 'text/html'; $body = new \Zend\Mime\Message(); $body->setParts(array($html)); $message->setBody($body); $message->setEncoding("UTF-8"); $smtp = new \Zend\Mail\Transport\Smtp(); $config = $this->getServiceLocator()->get('Config'); $options = new SmtpOptions($config['smtpOptions']); $smtp->setOptions($options); $smtp->send($message); $json = new JsonModel(); return $json->setVariable('Status', 'Đã xong'); } else { return 'Dữ liệu không phù hợp'; } } }
public function sendMail($post) { $options = new \Zend\Mail\Transport\SmtpOptions(array("name" => "localhost", "host" => "localhost", "connection_class" => "login", "connection_config" => array("username" => "*****@*****.**", "password" => "QHuMxhQQ"))); $message = array(); $ch1 = $post->checkbox1; $message[] = 'Отметьте пункты соответствующие интересам вашей компании:'; if (is_array($ch1)) { foreach ($ch1 as $chItem) { $message[] = $chItem; } } else { $message[] = $ch1; } $message[] = ''; $message[] = 'Пожалуйста, предоставьте нам ссылку на ваш веб-сайт:'; $message[] = $post->site ?: '-'; $ch2 = $post->checkbox2; $message[] = ''; $message[] = 'Отметьте пункты соответствующие вашей рекламной политике:'; if (is_array($ch2)) { foreach ($ch2 as $chItem) { $message[] = $chItem; } } else { $message[] = $ch2; } $message[] = ''; $message[] = 'Пожалуйста, предоставьте нам список ключевых слов, при поиске которых вы хотите занять место в Google/Yandex.'; $message[] = 'Тематика:' . $post->theme ?: '-'; $message[] = 'Ключи:' . $post->keys ?: '-'; $ch3 = $post->checkbox3; $message[] = ''; $message[] = 'Отметьте на каких социальных ресурсах представлена ваша компания:'; if (is_array($ch3)) { foreach ($ch3 as $chItem) { $message[] = $chItem; } } else { $message[] = $ch3; } $message[] = ''; $message[] = 'Пожалуйста, предоставьте нам ссылки для каждой из Ваших учетных записей в социальных сетях, перечисленных в предыдущем вопросе.'; $message[] = $post->links ?: '-'; $message[] = ''; $message[] = 'Пожалуйста, предоставьте нам любую дополнительную информацию о Вашем бизнесе, которая по вашему мнению может быть полезной'; $message[] = $post->info ?: '-'; $message[] = ''; $message[] = 'Ваше Имя:'; $message[] = $post->name ?: '-'; $message[] = ''; $message[] = 'Ваш адрес:'; $message[] = $post->adress_street ?: ' ' . ' - улица'; $message[] = $post->adress_city ?: ' ' . ' - город'; $message[] = $post->adress_region ?: ' ' . ' - область'; $message[] = $post->adress_index ?: ' ' . ' - индекс'; $message[] = $post->adress_country ?: ' ' . ' - страна'; $message[] = ''; $message[] = 'Email:'; $message[] = $post->email; $message[] = ''; $message[] = 'Phone:'; $message[] = $post->phone; $htmlPart = new \Zend\Mime\Part(implode("<br>", $message)); $htmlPart->type = "text/html"; $body = new \Zend\Mime\Message(); $body->setParts(array($htmlPart)); $msg = new \Zend\Mail\Message(); $msg->setFrom('*****@*****.**'); $msg->addTo('*****@*****.**'); $msg->setSubject('Новый заказ'); $msg->setEncoding('UTF-8'); $msg->setBody($body); $headers = $msg->getHeaders(); $headers->removeHeader('Content-Type'); $headers->addHeaderLine('Content-Type', 'text/html; charset=UTF-8'); $transport = new \Zend\Mail\Transport\Smtp(); $transport->setOptions($options); try { $transport->send($msg); } catch (Exception $e) { } return $message; }
public function mensajecomentarioAction() { $va_email = $this->params()->fromRoute('va_email', 0); $va_nombre_cliente = $this->params()->fromRoute('va_nombre_cliente', 0); $bodyHtml = '<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> </head> <body> <div style="color: #7D7D7D"><br /> Hola <strong style="color:#133088; font-weight: bold;">' . utf8_decode($va_nombre_cliente) . '</strong><br /> <br />Tu comentario ha sido eliminado por ser inapropiado<br/><br/> <br /><br /><hr /><br />Cordialmente,<br /><span style="color:#000; font-size: 18px; margin-top:8px;">El Equipo de listadelsabor.com</span><br /><br /> </div> </body> </html>'; $message = new Message(); $message->addTo($va_email, $va_nombre_cliente)->setFrom('*****@*****.**', 'listadelsabor.com')->setSubject('Moderación de comentario de ListaDelSabor.com'); $bodyPart = new \Zend\Mime\Message(); $bodyMessage = new \Zend\Mime\Part($bodyHtml); $bodyMessage->type = 'text/html'; $bodyPart->setParts(array($bodyMessage)); $message->setBody($bodyPart); $message->setEncoding('UTF-8'); $transport = $this->getServiceLocator()->get('mail.transport'); $transport->send($message); $this->redirect()->toUrl('/usuario/comentarios/index'); }
private function get_edition_mail($editionId, $target, $is_html = null) { global $prefs, $base_url; static $mailcache = array(); if (!isset($mailcache[$editionId])) { $tikilib = TikiLib::lib('tiki'); $headerlib = TikiLib::lib('header'); $info = $this->get_edition($editionId); $nl_info = $this->get_newsletter($info['nlId']); // build the html $beginHtml = '<body class="tiki_newsletters"><div id="tiki-center" class="clearfix content"><div class="wikitext">'; $endHtml = '</div></div></body>'; if ($is_html === null) { $is_html = $info['wysiwyg'] === 'y' && $prefs['wysiwyg_htmltowiki'] !== 'y'; // parse as html if wysiwyg and not htmltowiki } else { $is_html = !empty($is_html); } if (stristr($info['data'], '<body') === false) { $html = "<html>{$beginHtml}" . $tikilib->parse_data($info['data'], array('absolute_links' => true, 'suppress_icons' => true, 'is_html' => $is_html)) . "{$endHtml}</html>"; } else { $html = str_ireplace('<body>', $beginHtml, $info['data']); $html = str_ireplace('</body>', $endHtml, $html); } if ($nl_info['allowArticleClip'] == 'y' && $nl_info['autoArticleClip'] == 'y') { $articleClip = $this->clip_articles($nl_info['nlId']); $txtArticleClip = $this->generateTxtVersion($articleClip); $info['datatxt'] = str_replace('~~~articleclip~~~', $txtArticleClip, $info['datatxt']); $html = str_replace('~~~articleclip~~~', $articleClip, $html); if ($articleClip == '<div class="articleclip"></div>' && $nl_info['emptyClipBlocksSend'] == 'y') { return ''; } } if (stristr($html, '<base') === false) { if (stristr($html, '<head') === false) { $themelib = TikiLib::lib('theme'); $news_cssfile = $themelib->get_theme_path($prefs['theme'], '', 'newsletter.css'); $news_cssfile_option = $themelib->get_theme_path($prefs['theme'], $prefs['theme_option'], 'newsletter.css'); $news_css = ''; if (!empty($news_cssfile)) { $news_css .= $headerlib->minify_css($news_cssfile); } if (!empty($news_cssfile_option) && $news_cssfile_option !== $news_cssfile) { $news_css .= $headerlib->minify_css($news_cssfile_option); } if (empty($news_css)) { $news_css = $headerlib->get_all_css_content(); } $news_head = "<html><head><base href=\"{$base_url}\" /><style type=\"text/css\">{$news_css}</style></head>"; $html = str_ireplace('<html>', $news_head, $html); } else { $html = str_ireplace('<head>', "<head><base href=\"{$base_url}\" />", $html); } } $info['files'] = $this->get_edition_files($editionId); include_once 'lib/mail/maillib.php'; /* @var Zend\Mail\Message $zmail */ $zmail = tiki_get_admin_mail(); $emailMimeParts = array(); if (!empty($info['replyto'])) { $zmail->setReplyTo($info['replyto']); } foreach ($info['files'] as $f) { $fpath = isset($f['path']) ? $f['path'] : $prefs['tmpDir'] . '/newsletterfile-' . $f['filename']; $att = new Zend\Mime\Part(file_get_contents($fpath)); $att->filename = $f['name']; $att->type = $f['type']; $att->encoding = Zend\Mime\Mime::ENCODING_BASE64; $emailMimeParts[] = $att; } $zmail->setSubject($info['subject']); $mailcache[$editionId] = array('zmail' => $zmail, 'text' => $info['datatxt'], 'html' => $html, 'unsubMsg' => $nl_info['unsubMsg'], 'nlId' => $nl_info['nlId']); } $cache = $mailcache[$editionId]; $html = $cache['html']; $unsubmsg = ''; if ($cache["unsubMsg"] == 'y' && !empty($target["code"])) { $unsubmsg = $this->get_unsub_msg($cache["nlId"], $target['email'], $target['language'], $target["code"], $target['user']); if (stristr($html, '</body>') === false) { $html .= $unsubmsg; } else { $html = str_replace("</body>", nl2br($unsubmsg) . "</body>", $html); } } $zmail = $cache['zmail']; $textPart = new Zend\Mime\Part($cache['text'] . strip_tags($unsubmsg)); $textPart->setType(Zend\Mime\Mime::TYPE_TEXT); $emailMimeParts[] = $textPart; $htmlPart = new Zend\Mime\Part($html); $htmlPart->setType(Zend\Mime\Mime::TYPE_HTML); $emailMimeParts[] = $htmlPart; $emailBody = new \Zend\Mime\Message(); $emailBody->setParts($emailMimeParts); $zmail->setBody($emailBody); $zmail->getHeaders()->removeHeader('to'); $zmail->getHeaders()->removeHeader('cc'); $zmail->getHeaders()->removeHeader('bcc'); $zmail->addTo($target['email']); return $zmail; }