Beispiel #1
0
 public function getControllerPluginConfig()
 {
     return array('factories' => array('mailerZF2' => function ($sm) {
         $serviceLocator = $sm->getServiceLocator();
         $config = $serviceLocator->get('Configuration');
         if (!isset($config['email'])) {
             throw new \Exception('Configurazione delle mails non impostata.');
         }
         $renderer = new \Zend\View\Renderer\PhpRenderer();
         $resolver = new \Zend\View\Resolver\TemplatePathStack();
         $resolver->setPaths(array(__DIR__ . '/../../../module/'));
         $renderer->setResolver($resolver);
         $controllerPlugin = new Controller\Plugin\Mailer($renderer);
         $mail = $config['email']['credentials']['from_mail'];
         $name = $config['email']['credentials']['from_name'];
         $controllerPlugin->setFrom($mail, $name);
         switch ($config['email']['transport']) {
             case 'smtp':
                 $transport = new \Zend\Mail\Transport\Smtp();
                 $options = new \Zend\Mail\Transport\SmtpOptions(array('host' => $config['email']['smtp']['host'], 'port' => $config['email']['smtp']['port'], 'connection_class' => $config['email']['smtp']['connection_class'], 'connection_config' => $config['email']['smtp']['connection_config']));
                 $transport->setOptions($options);
                 $controllerPlugin->setMailTransport($transport);
                 break;
             case 'sendmail':
             default:
                 $transport = new \Zend\Mail\Transport\Sendmail();
                 $controllerPlugin->setMailTransport($transport);
                 break;
         }
         return $controllerPlugin;
     }));
 }
Beispiel #2
0
 public function getServiceConfig()
 {
     return array('factories' => array("Mail" => function ($sm) {
         $mail = new Mail();
         $mail->setRenderer($sm->get("ViewRenderer"));
         /**
          * @var $sm \Zend\ServiceManager\ServiceLocatorInterface
          */
         $config = $sm->get("config");
         $env = $config["env"]["type"];
         $transporterConfig = $config["WasabiMail"]["transporter"];
         $transporter = null;
         //Production
         if ($env == "production") {
             $transporter = new Sendmail();
         } elseif ($env == "develop") {
             $mailConfig = $transporterConfig["develop"];
             $mail->setTo($mailConfig["to"]);
             $transporter = new \Zend\Mail\Transport\Smtp();
             $options = new \Zend\Mail\Transport\SmtpOptions();
             $options->setName($mailConfig["name"]);
             $options->setHost($mailConfig["host"]);
             $options->setPort($mailConfig["port"]);
             if (isset($mailConfig['connection_class'])) {
                 $options->setConnectionClass($mailConfig['connection_class']);
             }
             if (isset($mailConfig['connection_config'])) {
                 $options->{$mailConfig}['connection_config'];
             }
             $transporter->setOptions($options);
         } elseif ($env == "local") {
             $fileConfig = $transporterConfig["local"];
             $options = new \Zend\Mail\Transport\FileOptions();
             $options->setPath($fileConfig["base"] . $fileConfig["target"]);
             $options->setCallback(function (\Zend\Mail\Transport\File $transport) {
                 return "Message_" . microtime(true) . "-" . mt_rand(0, 100) . ".txt";
             });
             $transporter = new \Zend\Mail\Transport\File($options);
         }
         $mail->setTransporter($transporter);
         return $mail;
     }));
 }
Beispiel #3
0
function tiki_mail_setup()
{
    static $done = false;
    if ($done) {
        return;
    }
    global $tiki_maillib__zend_mail_default_transport;
    global $prefs;
    if ($prefs['zend_mail_handler'] == 'smtp') {
        $options = array('host' => $prefs['zend_mail_smtp_server']);
        if ($prefs['zend_mail_smtp_auth']) {
            $options['connection_class'] = $prefs['zend_mail_smtp_auth'];
            $options['connection_config'] = array('username' => $prefs['zend_mail_smtp_user'], 'password' => $prefs['zend_mail_smtp_pass']);
        }
        if ($prefs['zend_mail_smtp_port']) {
            $options['port'] = $prefs['zend_mail_smtp_port'];
        }
        if ($prefs['zend_mail_smtp_security']) {
            $options['connection_config']['ssl'] = $prefs['zend_mail_smtp_security'];
        }
        if ($prefs['openpgp_gpg_pgpmimemail'] == 'y') {
            $transport = new OpenPGP_Zend_Mail_Transport_Smtp();
        } else {
            $transport = new Zend\Mail\Transport\Smtp();
        }
        $transportOptions = new Zend\Mail\Transport\SmtpOptions($options);
        $transport->setOptions($transportOptions);
    } elseif ($prefs['zend_mail_handler'] == 'file') {
        $transport = new Zend\Mail\Transport\File();
        $transportOptions = new Zend\Mail\Transport\FileOptions(array('path' => TIKI_PATH . '/temp', 'callback' => function ($transport) {
            return 'Mail_' . date('YmdHis') . '_' . mt_rand() . '.tmp';
        }));
        $transport->setOptions($transportOptions);
    } elseif ($prefs['zend_mail_handler'] == 'sendmail' && !empty($prefs['sender_email'])) {
        // from http://framework.zend.com/manual/1.12/en/zend.mail.introduction.html#zend.mail.introduction.sendmail
        $transport = new Zend\Mail\Transport\Sendmail('-f' . $prefs['sender_email']);
    } else {
        $transport = new Zend\Mail\Transport\Sendmail();
    }
    $tiki_maillib__zend_mail_default_transport = $transport;
    $done = true;
}
Beispiel #4
0
 public function run()
 {
     // Read the contents of the message in from the buffer
     $src = '';
     $stream = fopen($this->_emailSource, 'r');
     // The first line in the stream is a postfix message, so we discard it
     fgets($stream);
     while ($line = fgets($stream)) {
         $src .= $line;
     }
     fclose($stream);
     // Create a Zend\Mail\Message object with our message
     $email = \Zend\Mail\Message::fromString($src);
     $from = $email->getHeaders()->get('From')->getAddressList()->current()->getEmail();
     $email->setTo($from);
     // Create our transport
     $transport = new \Zend\Mail\Transport\Smtp();
     $options = new \Zend\Mail\Transport\SmtpOptions(array('host' => $this->_opts['smtp_server']));
     $transport->setOptions($options);
     $transport->send($email);
 }
Beispiel #5
0
 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';
         }
     }
 }
Beispiel #6
0
<?php

return array('controllers' => array('invokables' => array('Email\\Controller\\Email' => 'Email\\Controller\\EmailController')), 'router' => array('routes' => array('email' => array('type' => 'segment', 'options' => array('route' => '/email[/:action][/:id][/]', 'constraints' => array('action' => '[a-zA-Z][a-zA-Z0-9_-]*', 'id' => '[a-zA-Z0-9_-]*'), 'defaults' => array('controller' => 'Email\\Controller\\Email', 'action' => 'index'))))), 'view_manager' => array('template_path_stack' => array(__DIR__ . '/../view'), 'template_map' => array('email/default' => __DIR__ . '/../view/email/email/default.phtml', 'layout/html' => __DIR__ . '/../view/email/layout/html.phtml', 'layout/text' => __DIR__ . '/../view/email/layout/text.phtml'), 'layout' => 'layout/layout'), 'service_manager' => array('invokables' => array('Email\\Mapper\\Email' => 'Email\\Mapper\\Email', 'Email\\Entity\\Email' => 'Email\\Entity\\EmailEntity', 'Zend\\Mail' => 'Zend\\Mail'), 'factories' => array('email' => function ($sm) {
    $config = $sm->get('email\\get_config');
    $mapper = new Email\Mapper\Email();
    $mapper->setEntity(new Email\Entity\Email());
    $mapper->setPathStack($sm->get('ViewTemplateMapResolver'));
    $mapper->setConfig($config);
    // Select default transport based on config options
    if (strtolower($config['transport']['default']) == 'smtp') {
        $transport = new \Zend\Mail\Transport\Smtp();
        $transport->setOptions(new \Zend\Mail\Transport\SmtpOptions($config['transport']['options']));
    } elseif (strtolower($config['transport']['default']) == 'sendmail') {
        $transport = new \Zend\Mail\Transport\Sendmail();
    } else {
        // Default option
        $transport = new \Zend\Mail\Transport\Sendmail();
    }
    $mapper->setTransport($transport);
    return $mapper;
}, 'email\\get_config' => function ($sm) {
    $config = $sm->get('Config');
    return $config['mail'];
})));
Beispiel #7
0
 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);
 }
Beispiel #8
0
 /**
  * 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);
 }
Beispiel #9
0
 protected function getTransport()
 {
     if (!is_null($this->transport)) {
         return $this->transport;
     }
     $config = $this->getServiceLocator()->get('Config');
     // Select default transport based on config options
     if (strtolower($config['mail']['transport']['default']) == 'smtp') {
         $transport = new \Zend\Mail\Transport\Smtp();
         $transport->setOptions(new \Zend\Mail\Transport\SmtpOptions($config['mail']['transport']['options']));
     } else {
         // Default option
         $transport = new \Zend\Mail\Transport\Sendmail();
     }
     return $this->transport = $transport;
 }
Beispiel #10
0
 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);
     }
 }
Beispiel #11
0
 public function sendmailHTML($to_email, $to_name, $subject, $htmltext)
 {
     $message = new \Zend\Mail\Message();
     $message->addTo($to_email, $to_name)->setFrom('*****@*****.**', 'DiscoveryCRM')->setSubject($subject);
     // $htmltext = '<b>heii, <i>sorry</i>, i\'m going late</b>';
     if ($_SERVER['HTTP_HOST'] == 'localhost') {
         $transport = new \Zend\Mail\Transport\Smtp();
         $options = new \Zend\Mail\Transport\SmtpOptions(array('host' => 'smtp.gmail.com', 'connection_class' => 'login', 'connection_config' => array('ssl' => 'tls', 'username' => '*****@*****.**', 'password' => 'Discovery@123'), 'port' => 587));
         $html = new \Zend\Mime\Part($htmltext);
         $html->type = "text/html";
         $body = new \Zend\Mime\Message();
         $body->addPart($html);
         $message->setBody($body);
         $transport->setOptions($options);
         $transport->send($message);
     } else {
         $bodyPart = new \Zend\Mime\Message();
         $bodyMessage = new \Zend\Mime\Part($htmltext);
         $bodyMessage->type = 'text/html';
         $bodyPart->setParts(array($bodyMessage));
         $message->setBody($bodyPart);
         $message->setEncoding('UTF-8');
         $transport = new \Zend\Mail\Transport\Sendmail();
         $transport->send($message);
     }
     return 1;
 }
Beispiel #12
0
     $transport = new Zend\Mail\Transport\Sendmail();
 } else {
     switch ($state->universal['email']['transport']) {
         case 'SMTP':
             $transport = new \Zend\Mail\Transport\Smtp();
             $transportConfig = ['name' => $state->universal['email']['smtp']['name'], 'host' => $state->universal['email']['smtp']['host'], 'connection_class' => $state->universal['email']['smtp']['connection_class']];
             if ($state->universal['email']['smtp']['connection_class'] !== 'smtp') {
                 $transportConfig['connection_config'] = ['username' => $state->universal['email']['smtp']['username'], 'password' => $state->universal['email']['smtp']['password']];
             }
             if (!empty($state->universal['email']['smtp']['disable_tls'])) {
                 $transportConfig['connection_config']['port'] = !empty($state->universal['email']['smtp']['port']) ? $state->universal['email']['smtp']['port'] : 25;
             } else {
                 $transportConfig['connection_config']['ssl'] = 'tls';
                 $transportConfig['port'] = !empty($state->universal['email']['smtp']['port']) ? $state->universal['email']['smtp']['port'] : 587;
             }
             $transport->setOptions(new \Zend\Mail\Transport\SmtpOptions($transportConfig));
             break;
         case 'File':
             $transport = new Zend\Mail\Transport\File();
             /** @noinspection PhpUnusedParameterInspection */
             $transport->setOptions(new \Zend\Mail\Transport\FileOptions(['path' => !empty($state->universal['email']['file']['path']) ? $state->universal['email']['file']['path'] : ROOT . '/files/email', 'callback' => function (Zend\Mail\Transport\File $t) : string {
                 return \implode('_', ['Message', \date('YmdHis'), \Airship\uniqueId(12) . '.txt']);
             }]));
             break;
         case 'Sendmail':
             if (!empty($state->universal['email']['sendmail']['parameters'])) {
                 $transport = new Zend\Mail\Transport\Sendmail($state->universal['email']['sendmail']['parameters']);
             } else {
                 $transport = new Zend\Mail\Transport\Sendmail();
             }
             break;
Beispiel #13
0
            header('Retry-After: 300');
            $GLOBALS['user'] = null;
            $control->addValidationMessage('error', 'errore nelle nostre macchine');
            $template->setBlock('middle', 'error/middle.phtml');
            $template->setBlock('navigation', 'error/navigation.phtml');
            $template->render();
            break;
    }
    exit;
}
if ($config->mail_from == '') {
    throw new \Exception('Sender email is required', 1409011411);
}
if (!is_null($config->smtp)) {
    $transport = new Zend\Mail\Transport\Smtp();
    $transport->setOptions(new Zend\Mail\Transport\SmtpOptions($config->smtp->toArray()));
} else {
    $transport = new Zend\Mail\Transport\Sendmail();
}
if (PHP_SAPI != 'cli') {
    require 'session.php';
}
if (array_key_exists('autocomplete', $_GET) && array_key_exists('domain', $_GET)) {
    if (!array_key_exists('term', $_GET)) {
        $_GET['term'] = null;
    }
    $providerColl = new \abbrevia\domain\DomainColl($db);
    $providerColl->loadAll(array('cod_dominio' => $_GET['domain'], 'sSearch' => $_GET['term']));
    $result = array();
    foreach ($providerColl->getItems() as $item) {
        $result[] = array('label' => $item->getData($_GET['col'][1]), 'id' => $item->getData($_GET['col'][0]));
 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;
 }
Beispiel #15
0
 public function getServiceConfig()
 {
     return array('factories' => array('Application\\Model\\UsuarioTable' => function ($sm) {
         $tableGateway = $sm->get('UsuarioTableGateway');
         $table = new UsuarioTable($tableGateway);
         return $table;
     }, 'UsuarioTableGateway' => function ($sm) {
         $dbAdapter = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $resultSetPrototype = new ResultSet();
         $resultSetPrototype->setArrayObjectPrototype(new Usuario());
         return new TableGateway('ta_usuario', $dbAdapter, null, $resultSetPrototype);
     }, 'mail.transport' => function ($sm) {
         $config = $sm->get('config');
         $transport = new \Zend\Mail\Transport\Smtp();
         $transport->setOptions(new \Zend\Mail\Transport\SmtpOptions($config['mail']['transport']['options']));
         return $transport;
     }));
 }