public function process(ServerRequestInterface $request, DelegateInterface $delegate) : ResponseInterface
 {
     /* @var \PSR7Session\Session\SessionInterface $session */
     $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE);
     // Generate csrf token
     if (!$session->get('csrf')) {
         $session->set('csrf', md5(random_bytes(32)));
     }
     // Generate form and inject csrf token
     $form = new FormFactory($this->template->render('app::contact-form', ['token' => $session->get('csrf')]), $this->inputFilterFactory);
     // Validate form
     $validationResult = $form->validateRequest($request);
     if ($validationResult->isValid()) {
         // Get filter submitted values
         $data = $validationResult->getValues();
         $this->logger->notice('Sending contact mail to {from} <{email}> with subject "{subject}": {body}', $data);
         // Create the message
         $message = new Message();
         $message->setFrom($this->config['from'])->setReplyTo($data['email'], $data['name'])->setTo($this->config['to'])->setSubject('[xtreamwayz-contact] ' . $data['subject'])->setBody($data['body']);
         $this->mailTransport->send($message);
         // Display thank you page
         return new HtmlResponse($this->template->render('app::contact-thank-you'), 200);
     }
     // Display form and inject error messages and submitted values
     return new HtmlResponse($this->template->render('app::contact', ['form' => $form->asString($validationResult)]), 200);
 }
示例#2
0
 function send()
 {
     //第一步: 设置相关的headers
     //1.设置邮件的Content-Type,要不然网站的消息内容里面的html标签会被当做纯文本处理
     $smtpHeaderContentType = new SmtpHeaderContentType();
     $smtpHeaderContentType->setType('text/html');
     //2.设置编码集并添加Content-Type
     $headers = new SmtpHeaders();
     $headers->setEncoding('utf-8');
     $headers->addHeader($smtpHeaderContentType);
     //第二步:设置消息的相关
     $message = new SmtpMessage();
     $message->setHeaders($headers);
     $message->addTo($this->mailTo)->addFrom($this->mailFrom)->setSubject($this->subject)->setBody($this->body);
     //邮件的内容
     //第三步:设置Smtp的相关链接参数
     $smtpOptions = new SmtpOptions();
     $smtpOptions->setHost($this->host)->setPort($this->port)->setConnectionClass('login')->setConnectionConfig(array('username' => $this->username, 'password' => $this->password, 'ssl' => 'ssl'));
     //第四步:加载配置,发送消息
     $smtpTransport = new SmtpTransport();
     $smtpTransport->setOptions($smtpOptions);
     //加载配置
     $smtpTransport->send($message);
     //发送消息
 }
示例#3
0
 public function sendMail(MailMessage $message, string $templateName = null, array $params = [])
 {
     if (null !== $templateName) {
         $message->setBody($this->prepareBody($templateName, $params));
     }
     $this->mailer->sendMail($message);
 }
示例#4
0
 public function testTrue()
 {
     $message = new Message();
     $message->setSubject('Hundur')->setBody(file_get_contents(__DIR__ . '/mail.test.01.txt'))->addFrom('*****@*****.**', 'ble')->addTo('*****@*****.**', 'hundur');
     $attacher = new Attacher($message);
     $result = $attacher->parse();
 }
示例#5
0
 /**
  * Sends a mail with the given data from the AppMailAccount
  * @param string $to
  * @param string $subject
  * @param string $content
  */
 public function sendMail(string $to, string $subject, string $content, array $files = [])
 {
     $content .= "\n\nThis is an automated mail. Please don't respond.";
     $text = new Mime\Part($content);
     $text->type = 'text/plain';
     $text->charset = 'utf-8';
     $text->disposition = Mime\Mime::DISPOSITION_INLINE;
     $parts[] = $text;
     foreach ($files as $filePath) {
         $fileContent = file_get_contents($filePath);
         $attachment = new Mime\Part($fileContent);
         $attachment->type = 'image/' . pathinfo($filePath, PATHINFO_EXTENSION);
         $attachment->filename = basename($filePath);
         $attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         $attachment->encoding = Mime\Mime::ENCODING_BASE64;
         $parts[] = $attachment;
     }
     $mime = new Mime\Message();
     $mime->setParts($parts);
     $appMailData = $this->getAppMailData();
     $message = new Message();
     $message->addTo($to)->addFrom($appMailData->getAdress())->setSubject($subject)->setBody($mime)->setEncoding('utf-8');
     $transport = new SmtpTransport();
     $options = new SmtpOptions(['name' => $appMailData->getHost(), 'host' => $appMailData->getHost(), 'connection_class' => 'login', 'connection_config' => ['username' => $appMailData->getLogin(), 'password' => $appMailData->getPassword()]]);
     $transport->setOptions($options);
     $transport->send($message);
 }
示例#6
0
 /**
  * send
  *
  * @param ResetPassword $resetPassword
  * @param User $user
  * @param array $mailConfig
  *
  * @return mixed
  */
 public function sendRestPasswordEmail(ResetPassword $resetPassword, User $user, $mailConfig)
 {
     $toEmail = $user->getEmail();
     $fromEmail = $mailConfig['fromEmail'];
     $fromName = $mailConfig['fromName'];
     $subject = $mailConfig['subject'];
     $bodyTemplate = $mailConfig['body'];
     //Ignore blank emails
     if (!trim($toEmail)) {
         return;
     }
     $vars = ['name' => '', 'userId' => $user->getId(), 'url' => 'https://' . $_SERVER['HTTP_HOST'] . '/reset-password?fromPasswordResetEmail=1&id=' . $resetPassword->getResetId() . '&key=' . $resetPassword->getHashKey()];
     foreach ($vars as $name => $value) {
         $bodyTemplate = str_replace('__' . $name . '__', $value, $bodyTemplate);
         // Handle BC
         $bodyTemplate = str_replace('{' . $name . '}', $value, $bodyTemplate);
     }
     try {
         $html = new MimePart($bodyTemplate);
         $html->type = "text/html";
         $body = new MimeMessage();
         $body->setParts([$html]);
         $message = new Message();
         $message->setBody($body)->setFrom($fromEmail, $fromName)->setSubject($subject);
         foreach (explode(',', $toEmail) as $email) {
             $message->addTo(trim($email));
         }
         $transport = new \Zend\Mail\Transport\Sendmail();
         $transport->send($message);
     } catch (InvalidArgumentException $e) {
         // nothing
     }
 }
 /**
  * pack tagged array of data to SendMessage format
  *
  *
  * @param Array $mailArray
  *
  * return array of data that will be converted to
  * send message
  *
  * @return Array
  */
 public function packData($mailArray)
 {
     $mimeMail = new Message();
     $textPart = $this->packText($mailArray['text'], $mailArray['header']['content-type']);
     unset($mailArray['header']['content-type']);
     $attachmentParts = $this->packAttachments($mailArray['link']);
     if (count($attachmentParts)) {
         $mimeMail->addPart($textPart);
         foreach ($attachmentParts as $part) {
             $mimeMail->addPart($part);
         }
     } else {
         $mimeMail->addPart($textPart);
     }
     $returnMail = new SendMessage();
     $returnMail->setBody($mimeMail);
     foreach ($mailArray['header'] as $header => $value) {
         switch ($header) {
             case 'references':
                 if (is_array($value)) {
                     $res = '';
                     foreach ($value as $reference) {
                         $res .= $reference . ' ';
                     }
                 } elseif (is_string($value)) {
                     $res = $value;
                 } else {
                     continue;
                 }
                 $headers = $returnMail->getHeaders();
                 $headers->addHeaderLine($header, $res);
                 $returnMail->setHeaders($headers);
                 break;
             case 'bcc':
                 $returnMail->addBcc($value);
                 break;
             case 'cc':
                 $returnMail->addCc($value);
                 break;
             case 'to':
                 $returnMail->addTo($value);
                 break;
             case 'from':
                 $returnMail->addFrom($value);
                 break;
             case 'reply-to':
                 $returnMail->addReplyTo($value);
                 break;
             case 'subject':
                 $returnMail->setSubject($value);
                 break;
             default:
                 $headers = $returnMail->getHeaders();
                 $headers->addHeaderLine($header, $value);
                 $returnMail->setHeaders($headers);
                 break;
         }
     }
     return $returnMail;
 }
示例#8
0
 public function getMessage()
 {
     $message = new Message();
     $message->addTo('*****@*****.**', 'ZF DevTeam')->addCc('*****@*****.**')->addBcc('*****@*****.**', 'CR-Team, ZF Project')->addFrom(array('*****@*****.**', 'Matthew' => '*****@*****.**'))->setSender('*****@*****.**', 'Ralph Schindler')->setSubject('Testing Zend\\Mail\\Transport\\Sendmail')->setBody('This is only a test.');
     $message->getHeaders()->addHeaders(array('X-Foo-Bar' => 'Matthew'));
     return $message;
 }
示例#9
0
 /**
  * W momencie zapisu lokalizacji do bazy – wysyła się e-mail na stały adres administratora
  * serwisu z powiadomieniem o dodaniu nowej lokalizacji (nazwa miejsca + link do strony na froncie serwisu)
  *
  * @param Entity\Location $location
  */
 public function sendNotificationMail(Entity\Location $location)
 {
     /**
      * dane do wysylanego maila z potwierdzeniem, zdefiniowane w module.config.php
      */
     $config = $this->getServiceManager()->get('Config')['configuration']['location_mail_notification'];
     /* blokada wysylania maila (do testow) */
     if (false === $config['send_notification_mail']) {
         return false;
     }
     $uri = $this->getServiceManager()->get('request')->getUri();
     /* @var $uri \Zend\Uri\Http */
     $route = $this->getServiceManager()->get('router')->getRoute('location-details');
     /* @var $route \Zend\Mvc\Router\Http\Segment */
     /**
      * link do nowej lokalizacji
      */
     $base = sprintf('%s://%s', $uri->getScheme(), $uri->getHost());
     $url = $route->assemble(array('id' => $location->getId()));
     $mailConfig = (object) $config['message_config'];
     $html = strtr($mailConfig->message, array('%name%' => $location->getName(), '%link%' => $base . $url));
     $message = new Mime\Message();
     $message->setParts(array((new Mime\Part($html))->setType('text/html')));
     $mail = new Mail\Message();
     $mail->setBody($message)->setFrom($mailConfig->from_email, $mailConfig->from_name)->addTo($mailConfig->to_email, $mailConfig->to_name)->setSubject($mailConfig->subject);
     $transport = new Mail\Transport\Smtp(new Mail\Transport\SmtpOptions($config['smtp_config']));
     $transport->send($mail);
 }
示例#10
0
 public function sendMessage(Message $message, Smtp $smtp, $recipient)
 {
     $message->addTo($recipient);
     if (!$this->config['disable_delivery']) {
         $smtp->send($message);
     }
 }
示例#11
0
 /**
  * Send a mail message
  *
  * @param Mail\Message $message
  * @return array
  */
 public function send(Mail\Message $message)
 {
     $this->getMandrillClient();
     $body = $message->getBody();
     $attachments = [];
     switch (true) {
         case $body instanceof Message:
             $bodyHtml = $this->getHtmlPart($body);
             $bodyText = $this->getTextPart($body);
             $attachments = $this->getAttachments($body);
             break;
         case is_string($body):
             $bodyHtml = $body;
             $bodyText = $message->getBodyText();
             break;
         case is_object($body):
             $bodyHtml = $body->__toString();
             $bodyText = $message->getBodyText();
             break;
         default:
             throw new Exception\InvalidArgumentException(sprintf('"%s" expectes a body that is a string, an object or a Zend\\Mime\\Message; received "%s"', __METHOD__, is_object($body) ? get_class($body) : gettype($body)));
             break;
     }
     $message = ['html' => $bodyHtml, 'text' => $bodyText, 'subject' => $message->getSubject(), 'from_email' => $message->getFrom()->current()->getEmail(), 'from_name' => $message->getFrom()->current()->getName(), 'to' => array_merge($this->mapAddressListToArray($message->getTo(), 'to'), $this->mapAddressListToArray($message->getCc(), 'cc'), $this->mapAddressListToArray($message->getBcc(), 'bcc')), 'headers' => $message->getHeaders()->toArray(), 'subaccount' => $this->options->getSubAccount(), 'attachments' => $attachments];
     return $this->mandrillClient->messages->send($message);
 }
示例#12
0
 protected function send()
 {
     try {
         $message = new Message();
         $para = array_filter(explode(";", str_replace(array(" ", ","), array("", ";"), $this->dados["para"])));
         $message->addTo($para)->addFrom($this->dados["de"]["email"], $this->dados["de"]["nome"])->setSubject($this->dados["assunto"])->addReplyTo($this->dados["replay"]);
         $transport = new SmtpTransport();
         $options = new SmtpOptions(array('host' => 'mail.pessoaweb.com.br', 'connection_class' => 'login', 'connection_config' => array('username' => '*****@*****.**', 'password' => 'd1i2s3p4atch'), 'port' => 587));
         $html = new MimePart($this->dados["body"]);
         $html->type = "text/html";
         $html->charset = "UTF-8";
         $body = new MimeMessage();
         if (isset($this->dados["attachment"])) {
             foreach ($this->dados["attachment"] as $valor) {
                 $attachment = new MimePart($valor["arquivo"]);
                 $attachment->filename = $valor["titulo"];
                 if (isset($valor["tipo"])) {
                     $attachment->type = $valor["tipo"];
                 }
                 $attachment->disposition = Mime::DISPOSITION_ATTACHMENT;
                 $attachment->encoding = Mime::ENCODING_BASE64;
                 $body->setParts(array($attachment));
             }
         }
         $body->addPart($html);
         $message->setBody($body);
         $transport->setOptions($options);
         $transport->send($message);
         return $transport;
     } catch (\Exception $e) {
         debug(array("email" => $e->getMessage()), true);
     }
 }
 static function sendEmail($emailTo, $emailFrom, $subject, $body, $transport)
 {
     $message = new Message();
     $message->setEncoding('UTF-8')->addTo($emailTo)->addFrom($emailFrom)->setSubject($subject)->setBody($body);
     $transport->send($message);
     return;
 }
 /**
  * @inheritDoc
  */
 public static function fromWrappedMessage(MailWrappedMessage $wrappedMessage = null, $transport = null)
 {
     if (!$wrappedMessage instanceof MailWrappedMessage) {
         throw new MailWrapperSetupException('Not MailWrappedMessage');
     }
     $message = new Message();
     foreach ($wrappedMessage->getToRecipients() as $address) {
         $message->addTo($address);
     }
     foreach ($wrappedMessage->getCcRecipients() as $address) {
         $message->addCc($address);
     }
     foreach ($wrappedMessage->getBccRecipients() as $address) {
         $message->addBcc($address);
     }
     $message->setReplyTo($wrappedMessage->getReplyTo());
     $message->setFrom($wrappedMessage->getFrom());
     $message->setSubject($wrappedMessage->getSubject());
     if ($wrappedMessage->getContentText()) {
         $message->setBody($wrappedMessage->getContentText());
     }
     if ($wrappedMessage->getContentHtml()) {
         $html = new MimePart($wrappedMessage->getContentHtml());
         $html->type = "text/html";
         $message->setBody($body);
     }
     return $message;
 }
示例#15
0
 /**
  * @param string $queue_name
  * @param \Zend\Mail\Message $mail
  */
 public function add($queue_name, \Zend\Mail\Message $message)
 {
     if (!count($message->getFrom())) {
         $message->addFrom($this->config['default_from']);
     }
     $this->table->add($queue_name, $message);
 }
示例#16
0
 /**
  * @param ZendMail\Message $message
  * @param string $emailAlias
  * @param array $variables
  * @return ZendMail\Message
  * @throws Exception\RuntimeException
  */
 public function sendMail(ZendMail\Message $message, $emailAlias, array $variables = array())
 {
     $plain = $this->renderMessage($emailAlias, Config::TYPE_PLAIN, $variables);
     $html = $this->renderMessage($emailAlias, Config::TYPE_HTML, $variables);
     $body = new Mime\Message();
     if (!empty($html) && !empty($plain)) {
         $htmlPart = new Mime\Part($html);
         $htmlPart->type = 'text/html';
         $plainPart = new Mime\Part($plain);
         $plainPart->type = 'text/plain';
         $body->setParts(array($plainPart, $htmlPart));
     } elseif (!empty($html)) {
         $htmlPart = new Mime\Part($html);
         $htmlPart->type = 'text/html';
         $body->setParts(array($htmlPart));
     } else {
         $plainPart = new Mime\Part($plain);
         $plainPart->type = 'text/plain';
         $body->setParts(array($plainPart));
     }
     $from = $this->getConfig()->getFrom($emailAlias);
     $message->setSubject($this->getSubject($emailAlias, $variables))->setEncoding('UTF-8')->setBody($body)->setFrom($from['email'], $from['name']);
     if (count($body->getParts()) == 2) {
         $message->getHeaders()->get('content-type')->setType('multipart/alternative');
     }
     if (null === ($transport = $this->getTransport())) {
         throw new Exception\RuntimeException('No transport could be alocated');
     }
     $transport->send($message);
     return $message;
 }
示例#17
0
 public function submitAction()
 {
     $result = "";
     $contact = $this->params()->fromPost();
     $captcha = new Captcha(array('name' => 'captcha', 'wordLen' => 6, 'timeout' => 600));
     if ($captcha->isValid($_POST['captcha'], $_POST)) {
         unset($contact['submit']);
         $contact = array_filter($contact);
         if ($contact && is_array($contact)) {
             $mail = new Mail\Message();
             $html = '<p>Contact from Kingsy.co.uk</p><p>=-=-=-=-=-=-=-=-=-=-=-=-=-=</p><p><span></span>From: <span>' . $contact["name"] . '</span></p><p><span></span>Email: <span>' . $contact["email"] . '</span></p><p><span></span>Content<p>' . $contact["content"] . '</p></p>';
             $mail->setFrom('*****@*****.**', 'Contact Form - Kingsy.co.uk')->addTo("*****@*****.**")->setSubject('Contacted');
             $bodyPart = new MimeMessage();
             $bodyMessage = new MimePart($html);
             $bodyMessage->type = 'text/html';
             $bodyPart->setParts(array($bodyMessage));
             $mail->setBody($bodyPart);
             $mail->setEncoding('UTF-8');
             try {
                 $transport = new Mail\Transport\Sendmail();
                 $transport->send($mail);
                 $result = true;
             } catch (Exception $e) {
                 print_r($e);
             }
         } else {
             $result = false;
         }
     } else {
         $result = false;
     }
     return new ViewModel(array('result' => $result));
 }
示例#18
0
 /**
  * @param Message $message
  */
 public function send(Message $message)
 {
     if (!count($message->getFrom())) {
         $message->setFrom('*****@*****.**', 'US Canine Scent Sports');
     }
     $transport = new Transport\Smtp();
     $transport->setOptions($this->transportOptions)->send($message);
 }
示例#19
0
 /**
  * Send an e-mail
  * @param   array  $recipients  An array of the recipients. The key represents the e-mail address, the value is the displayname
  * @param   type   $subject     The subject of the message
  * @param   type   $message     The message body
  * @return  void
  */
 public function email($recipients, $subject, $message)
 {
     $beehubConfig = \BeeHub::config();
     $config = $beehubConfig['email'];
     $mail = new Mail\Message();
     $mail->setBody($message)->addTo($recipients)->setSubject($subject)->setFrom($config['sender_address'], $config['sender_name'])->setEncoding('UTF-8');
     $this->emailer->send($mail);
 }
示例#20
0
 /**
  * Gets a mail message with some of the fields populated.
  * @return Message
  */
 public function getMessage()
 {
     /** @var MessageConfig $messageConfig */
     $messageConfig = $this->serviceLocator->get('mail_message_config');
     $mail = new Message();
     $mail->setFrom($messageConfig->getFrom(), $messageConfig->getFromName());
     return $mail;
 }
示例#21
0
 public function sendMail(MailMessage $message)
 {
     $from = $message->getFrom();
     if (count($from) == 0) {
         $message->addFrom($this->createSenderAddress());
     }
     $this->transport->send($message);
 }
示例#22
0
 /**
  * Creates a new message with some of the fields populated.
  *
  * @return Message
  */
 private function newMessage()
 {
     /* @var $config ModuleOptions */
     $config = $this->serviceLocator->get('EscoMail\\Options');
     $this->message = new Message();
     $this->message->setFrom($config->getMailSendFrom(), $config->getMailSendFromName());
     return $this->message;
 }
示例#23
0
 /**
  * @expectedException \Mandrill_Invalid_Key
  */
 public function testSendObject()
 {
     $message = new Message();
     $body = new ToStringObject();
     $body->addElement('one')->addElement('two')->addElement('three');
     $message->setBody($body);
     $message->setFrom('*****@*****.**');
     $this->mandrill->send($message);
 }
示例#24
0
 private function sendMailRegisterConfirm($contactData)
 {
     //        print_r($contactData);die;
     $mailer = $this->getServiceLocator()->get('Mailer');
     $message = new MailMessage();
     $message->setBody('El Mensaje es: ' . $contactData['messaje']);
     $message->addTo($contactData['email'])->addFrom($contactData['email'])->setSubject('Contacto Solicitado por Doggerout.com por ' . $contactData['name']);
     $sendMail = $mailer->send($message);
     return $sendMail;
 }
示例#25
0
 public function testSendMinimalMail()
 {
     $headers = new Headers();
     $headers->addHeaderLine('Date', 'Sun, 10 Jun 2012 20:07:24 +0200');
     $message = new Message();
     $message->setHeaders($headers)->setSender('*****@*****.**', 'Ralph Schindler')->setBody('testSendMailWithoutMinimalHeaders')->addTo('*****@*****.**', 'ZF DevTeam');
     $expectedMessage = "RSET\r\n" . "MAIL FROM:<*****@*****.**>\r\n" . "DATA\r\n" . "Date: Sun, 10 Jun 2012 20:07:24 +0200\r\n" . "Sender: Ralph Schindler <*****@*****.**>\r\n" . "To: ZF DevTeam <*****@*****.**>\r\n" . "\r\n" . "testSendMailWithoutMinimalHeaders\r\n" . ".\r\n";
     $this->transport->send($message);
     $this->assertEquals($expectedMessage, $this->connection->getLog());
 }
示例#26
0
 public function sendMail()
 {
     $message = new Message();
     $message->addTo('*****@*****.**')->addFrom('*****@*****.**')->setSubject('Greetings and Salutations!')->setBody("Sorry, I’m going to be late today!");
     // Setup SMTP transport using LOGIN authentication
     $transport = new SmtpTransport();
     $options = new SmtpOptions(array('name' => 'localhost.localdomain', 'host' => '127.0.0.1', 'connection_class' => 'login', 'connection_config' => array('username' => 'user', 'password' => 'pass')));
     $transport->setOptions($options);
     $transport->send($message);
 }
示例#27
0
 public function testSendEscapedEmail()
 {
     $headers = new Headers();
     $headers->addHeaderLine('Date', 'Sun, 10 Jun 2012 20:07:24 +0200');
     $message = new Message();
     $message->setHeaders($headers)->setSender('*****@*****.**', 'Ralph Schindler')->setBody("This is a test\n.")->addTo('*****@*****.**', 'ZF DevTeam');
     $expectedMessage = "EHLO localhost\r\n" . "MAIL FROM:<*****@*****.**>\r\n" . "DATA\r\n" . "Date: Sun, 10 Jun 2012 20:07:24 +0200\r\n" . "Sender: Ralph Schindler <*****@*****.**>\r\n" . "To: ZF DevTeam <*****@*****.**>\r\n" . "\r\n" . "This is a test\r\n" . "..\r\n" . ".\r\n";
     $this->transport->send($message);
     $this->assertEquals($expectedMessage, $this->connection->getLog());
 }
示例#28
0
 /**
  * @param \Zend\Mail\Message $message
  * @param string $toEmail
  *
  * @return string
  */
 public function send($message, $toEmail)
 {
     if (YII_ENV == 'test' || mb_strpos($toEmail, '@example.org') !== false) {
         return Email::STATUS_SKIPPED_OTHER;
     }
     $message->setTo($toEmail);
     $transport = $this->getTransport();
     $transport->send($message);
     return Email::STATUS_SENT;
 }
示例#29
0
文件: Assembler.php 项目: t4web/mail
 /**
  * @param string $to
  * @param Template $template
  * @param array $data
  * @return Message
  */
 public function assemble($to, Template $template, array $data)
 {
     $html = new MimePart($template->getBody($data));
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->addPart($html);
     $message = new Message();
     $message->addFrom($this->config['from-email'], $this->config['from-name'])->addTo($to)->setSubject($template->getSubject())->setBody($body)->setEncoding("UTF-8");
     return $message;
 }
示例#30
0
 public function sendNewsMail(array $email, array $tags, $projectName)
 {
     $translator = $this->getTranslator();
     $mail = new MailMessage();
     $mail->setSubject(sprintf($translator->translate('send.news.from.%s'), $projectName));
     $this->addTarget($email, $username);
     $viewVariables = ['projectName' => $projectName, 'username' => $username];
     $this->prepareMail($mail, $viewVariables, 'mail/send-news.phtml');
     $this->sendMail($mail);
 }