/**
  * Build Message
  *
  * @return MailMessage
  */
 public function buildMessage()
 {
     // prepare html body
     $htmlBody = $this->renderer->render($this->viewModel);
     // prepare text body
     $textBody = $this->buildTextBody($htmlBody);
     // prepare subject
     $subject = $this->buildSubject($htmlBody);
     // prepare html part
     $htmlPart = new MimePart($this->buildHtmlHeader() . $htmlBody . $this->buildHtmlFooter());
     $htmlPart->type = 'text/html';
     // prepare text part
     $textPart = new MimePart($textBody);
     $textPart->type = 'text/plain';
     // prepare mime message
     $mailBody = new MimeMessage();
     $mailBody->setParts(array($textPart, $htmlPart));
     // prepare message
     $this->message = new MailMessage();
     $this->message->setEncoding($this->encoding);
     $this->message->setFrom($this->senderMail, $this->senderName);
     $this->message->setSubject($subject);
     $this->message->setBody($mailBody);
     // return mailer
     return $this;
 }
 public function addAction()
 {
     $form = new BookForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $book = new Book();
         $form->setInputFilter($book->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $book->exchangeArray($form->getData());
             $this->getBookTable()->saveBook($book);
             //send email
             $mail = new Mail\Message();
             $mail->setBody('A new book called ' . $book->title . ' has been added.');
             $mail->setFrom('*****@*****.**', 'Zend Course');
             $mail->addTo('*****@*****.**', 'Myself');
             $mail->setSubject('A Book was added');
             $transport = new Mail\Transport\Sendmail();
             $transport->send($mail);
         }
         //Redirect to books list
         return $this->redirect()->toRoute('book');
     }
     return array('form' => $form);
 }
 /**
  * Add Action
  * <br/> Responsible for :
  *       <br/>In case Get verb  -> Display Add new Book Form
  *       <br/>In case Post verb -> Add new book details into Database
  *                                 After Submit Book Form
  * @return ViewModel add view
  */
 public function addAction()
 {
     $form = new BookForm();
     $form->get('submit')->setValue('Add');
     // Another way to set Submit button value
     // $form->get('submit')->setAttribute('value', 'Add');
     $request = $this->getRequest();
     // Check If request is Post verb
     if ($request->isPost()) {
         $book = new Book();
         $form->setInputFilter($book->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $book->exchangeArray($form->getData());
             $this->getBookTable()->saveBook($book);
             //Send an email when a new book Was Added
             $mail = new Mail\Message();
             $mail->setBody('A new Book called ' . $book->title . ' has been added.');
             $mail->setFrom('*****@*****.**', 'Zend course');
             $mail->addTo('*****@*****.**', 'Ahmed Hamdy');
             $mail->setSubject('A Book was Added');
             $transport = new Mail\Transport\Sendmail();
             $transport->send($mail);
         }
         // redirect to list of books
         return $this->redirect()->toRoute('book');
     }
     return new ViewModel(array('form' => $form));
 }
Exemple #4
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;
 }
Exemple #5
0
 public function send($fromAddress, $fromName, $replyToAddress, $replyToName, $toAddress, $toName, $subject, array $mimeParts)
 {
     $mail = new Message();
     if ($fromAddress && $fromName) {
         $mail->setFrom($fromAddress, $fromName);
     } else {
         if ($fromAddress) {
             $mail->setFrom($fromAddress);
         }
     }
     if ($replyToAddress && $replyToName) {
         $mail->setReplyTo($replyToAddress, $replyToName);
     } else {
         if ($replyToAddress) {
             $mail->setReplyTo($replyToAddress);
         }
     }
     if ($toAddress && $toName) {
         $mail->setTo($toAddress, $toName);
     } else {
         if ($toAddress) {
             $mail->setTo($toAddress);
         }
     }
     $mail->setSubject($subject);
     $mail->setEncoding('utf-8');
     $mime = new MimeMessage();
     $mime->setParts($mimeParts);
     $mail->setBody($mime);
     $this->mailTransport->send($mail);
     $this->getEventManager()->trigger('send', $mail);
 }
Exemple #6
0
 /**
  * @param Message $message
  * @return Message
  */
 public function render(Message $message)
 {
     $viewModel = new ViewModel($this->variables);
     $viewModel->setTemplate($this->template);
     $helperPluginManager = $this->renderer->getHelperPluginManager();
     /** @var HeadTitle $helper */
     $helper = $helperPluginManager->get('HeadTitle');
     // replace headTitle
     $headTitle = new HeadTitle();
     $headTitle->setAutoEscape(false);
     $helperPluginManager->setAllowOverride(true);
     $helperPluginManager->setService('HeadTitle', $headTitle);
     if (!$message->getBody()) {
         $message->setBody(new MimeMessage());
     }
     $text = new Part($this->renderer->render($viewModel));
     $text->charset = 'UTF-8';
     $text->boundary = $message->getBody()->getMime()->boundary();
     $text->encoding = Mime::ENCODING_BASE64;
     $text->type = Mime::TYPE_HTML;
     $message->getBody()->addPart($text);
     $message->setSubject($headTitle->renderTitle());
     // hack for ZF
     $message->setBody($message->getBody());
     // restore original helper
     $helperPluginManager->setService('HeadTitle', $helper);
     return $message;
 }
 public function indexAction()
 {
     $form = $this->getServiceLocator()->get('form.contact');
     if ($this->getRequest()->isPost()) {
         $post = $this->getRequest()->getPost()->toArray();
         $form->setData($post);
         if ($form->isValid()) {
             $content = 'Name: ' . $post['name'] . "\n";
             $content .= 'Email: ' . $post['email'] . "\n";
             $content .= 'Message: ' . "\n" . $post['message'];
             $message = new Message();
             $message->addTo('*****@*****.**');
             $message->setSubject('MajorApps website contact');
             $message->setBody($content);
             $message->setFrom('*****@*****.**');
             /** @var Smtp $transport */
             $transport = $this->getServiceLocator()->get('mail.transport');
             $transport->send($message);
             // Fallback in-case email fails
             $content = '=======================================' . "\n" . date('Y-m-d H:i:s') . "\n" . $content . "\n" . '=======================================' . "\n";
             file_put_contents(__DIR__ . '/../../../../../data/message.txt', $content, FILE_APPEND);
             $this->flashMessenger()->addSuccessMessage('Message sent successfully');
             return $this->redirect()->toRoute('home');
         } else {
             $this->flashMessenger()->addErrorMessage('Message was not sent successfully');
         }
     }
     return new ViewModel(['form' => $form, 'jargon' => $this->getJargon(), 'features' => $this->getFeatures()]);
 }
Exemple #8
0
 public function send($subject, $text, $to, $from = null)
 {
     if (!config('mail.enabled')) {
         return;
     }
     $message = new Message();
     $message->setSubject($subject);
     if ($from) {
         if (is_array($from)) {
             $message->setFrom($from[0], $from[1]);
         } else {
             $message->setFrom($from);
         }
     }
     $message->addTo($to);
     $content = '<html><head><title>' . $subject . '</title></head><body>' . $text . '</body></html>';
     $html = new Mime\Part($content);
     $html->setType(Mime\Mime::TYPE_HTML);
     $html->setCharset('utf-8');
     $mimeMessage = new Mime\Message();
     $mimeMessage->addPart($html);
     foreach ($this->attachments as $attachment) {
         $mimeMessage->addPart($attachment);
     }
     $message->setBody($mimeMessage);
     try {
         $transport = new SmtpTransport(new SmtpOptions(config('mail.options')));
         $transport->send($message);
     } catch (\Exception $e) {
         throw $e;
     }
     return $this;
 }
Exemple #9
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();
 }
 public function sendEmail($from, $to, $cc, $subject, $body, $attachmentFilename)
 {
     $message = new Message();
     $message->setFrom($from);
     $message->setTo($to);
     $message->setCc($cc);
     $message->setSubject($subject);
     $mimeMessage = new \Zend\Mime\Message();
     $part = new \Zend\Mime\Part($body);
     $part->setType(Mime::TYPE_TEXT);
     $part->setCharset('UTF-8');
     $mimeMessage->addPart($part);
     $part = new \Zend\Mime\Part('<p>' . $body . '<p>');
     $part->setType(Mime::TYPE_HTML);
     $part->setCharset('UTF-8');
     $mimeMessage->addPart($part);
     $part = new \Zend\Mime\Part($body);
     $part->setType(Mime::TYPE_OCTETSTREAM);
     $part->setEncoding(Mime::ENCODING_BASE64);
     $part->setFileName($attachmentFilename);
     $part->setDisposition(Mime::DISPOSITION_ATTACHMENT);
     $mimeMessage->addPart($part);
     $message->setBody($mimeMessage);
     $this->transport->send($message);
     $this->debugSection('ZendMailer', $subject . ' ' . $from . ' -> ' . $to);
 }
 /**
  * Sends the contact message via email
  *
  * @param array $data
  * @return boolean
  **/
 public function send($data)
 {
     $form = $this->getForm();
     $form->setData($data);
     if ($form->isValid()) {
         $data = $form->getData();
         $message = 'Name: ' . $data['name'] . "\r\n";
         $message .= 'Email: ' . $data['email'] . "\r\n\r\n";
         $message .= $data['comment'];
         $mail = new Message();
         $mail->setBody($message);
         $mail->setFrom('*****@*****.**');
         $mail->addTo('*****@*****.**', 'Rob Keplin');
         $mail->setSubject('From robkeplin.com');
         $transport = new Sendmail();
         try {
             $transport->send($mail);
         } catch (RuntimeException $e) {
             $this->addMessage('The email did not get sent due to sendmail failing. Doh!', self::MSG_ERROR);
             return false;
         }
         $form->setData(array('name' => '', 'email' => '', 'comment' => ''));
         $this->addMessage('Thanks.  Get back to you soon!', self::MSG_NOTICE);
         return true;
     }
     $this->addMessage('Hey, Wait! Something went wrong down there.  Please fix the errors and try again.', self::MSG_ERROR);
     return false;
 }
 /**
  * Send email to contacts, insert message into db, log operation
  */
 public function sendAction()
 {
     $form = new ContactsForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $mainLayout = $this->initializeFrontendWebsite();
         $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
         $inputFilter = new ContactsFormInputFilter();
         $form->setInputFilter($inputFilter->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $inputFilter->exchangeArray($form->getData());
             $formData = $request->getPost();
             $configurations = $this->layout()->getVariable('configurations');
             $mail = new Mail\Message();
             $mail->setFrom($configurations['emailnoreply'], $formData->nome . ' ' . $formData->cognome);
             $mail->addTo($configurations['emailcontact'], $configurations['sitename']);
             $mail->setSubject('Nuovo messaggio dal sito ' . $configurations['sitename']);
             $mail->setBody("Nome e cognome: \n " . $formData->nome . " " . $formData->cognome . " Email: " . $formData->email . "\n Messaggio: " . $formData->messaggio);
             $transport = new Mail\Transport\Sendmail();
             $transport->send($mail);
             $helper = new ContactsControllerHelper();
             $helper->setConnection($em->getConnection());
             $helper->insert($inputFilter);
             $this->layout()->setVariables(array('configuraitions' => $configurations, 'homepage' => !empty($homePageElements) ? $homePageElements : null, 'templatePartial' => 'contatti/ok.phtml'));
             $this->layout()->setTemplate($mainLayout);
         } else {
             foreach ($form->getInputFilter()->getInvalidInput() as $invalidInput) {
                 var_dump($form->getMessages());
             }
             exit;
         }
     }
 }
Exemple #13
0
 /**
  * @param string $subject
  * @param string $message
  * @param null|string|array $to
  * @param null|string|array $cc
  * @param null|string|array $bcc
  * @return array
  */
 public function sendMail($subject, $message, $to = null, $cc = null, $bcc = null)
 {
     $return = array('success' => true, 'msg' => null);
     $partBody = new MimePart($this->getPartHeader() . $message . $this->getPartFooter());
     $partBody->type = Mime::TYPE_HTML;
     $partBody->charset = 'utf-8';
     $this->body->setParts(array($partBody));
     $subject = '[' . APPLICATION_NAME . '] ' . $subject;
     $mail = new Message();
     $mail->addFrom(self::FROM);
     $mail->setSubject($subject);
     $mail->setBody($this->body);
     $mail->setTo($to);
     if ($cc) {
         $mail->setCc($cc);
     }
     if ($bcc) {
         $mail->setBcc($bcc);
     }
     try {
         $this->transport->send($mail);
     } catch (\Exception $e) {
         $return['success'] = false;
         $return['msg'] = _('mail.message.not_sent');
         //throw new \Exception($e->getMessage(), $e->getCode());
     }
     return $return;
 }
 protected function sendOfflineMessage($msgSubj, $msgText, $fromUserId, $toUserId)
 {
     $userTable = $this->getServiceLocator()->get('UserTable');
     $fromUser = $userTable->getById($fromUserId);
     $toUser = $userTable->getById($toUserId);
     $mail = new Mail\Message();
     $mail->setFrom($fromUser->getEmail(), $fromUser->getName());
     $mail->addTo($toUser->getEmail(), $toUser->getName());
     $mail->setSubject($msgSubj);
     $mail->setBody($msgText);
     $transport = new Mail\Transport\Sendmail();
     //        $transport = new Mail\Transport\Smtp();
     //        $options   = new Mail\Transport\SmtpOptions(array(
     //            'name'              => 'smtp.gmail.com',
     //            'host'              => 'smtp.gmail.com',
     //            'connection_class'  => 'login',
     //            'connection_config' => array(
     //                'ssl'      => 'tls',
     //                'username' => '*****@*****.**',
     //                'password' => '',
     //            ),
     //        ));
     //        $transport->setOptions($options);
     $transport->send($mail);
     return true;
 }
Exemple #15
0
    /**
     * Sends award certificate
     *
     * @param \User\Model\Entity\User $user
     * @param array $exam
     * @param \ZendPdf\Document $pdf
     */
    public function sendCertificate($user, $exam, $pdf)
    {
        $translator = $this->services->get('translator');
        $mail = new Message();
        $mail->addTo($user->getEmail(), $user->getName());
        $text = 'You are genius!
You answered all the questions correctly.
Therefore we are sending you as a gratitude this free award certificate.

';
        // we create a new mime message
        $mimeMessage = new MimeMessage();
        // create the original body as part
        $textPart = new MimePart($text);
        $textPart->type = "text/plain";
        // add the pdf document as a second part
        $pdfPart = new MimePart($pdf->render());
        $pdfPart->type = 'application/pdf';
        $mimeMessage->setParts(array($textPart, $pdfPart));
        $mail->setBody($mimeMessage);
        $mail->setFrom('*****@*****.**', 'Slavey Karadzhov');
        $mail->setSubject($translator->translate('Congratulations: Here is your award certificate'));
        $transport = $this->services->get('mail-transport');
        $transport->send($mail);
    }
Exemple #16
0
 /**
  * Parse the subject of the email.
  */
 public function parseSubject()
 {
     //Transfer first the subject form the email (if any)
     $this->message->setSubject($this->email->getSubject());
     /*
      * When the subject is empty AND we have a template, simply take the subject of the template
      */
     if (!empty($this->message->getSubject()) && !is_null($this->template)) {
         $this->message->setSubject($this->template->getSubject());
     }
     /*
      * Go over the templateVars to replace content in the subject
      */
     foreach ($this->templateVars as $key => $replace) {
         /*
          * Skip the service manager
          */
         if ($replace instanceof ServiceManager) {
             continue;
         }
         /*
          * replace the content of the title with the available keys in the template vars
          */
         if (!is_array($replace)) {
             $this->message->setSubject(str_replace(sprintf("[%s]", $key), $replace, $this->message->getSubject()));
         }
     }
 }
 public function sendCareerMail($sender, $recipient, $subject, $text, $filepath, $candidateName)
 {
     $result = false;
     try {
         //add attachment
         $text = new Mime\Part($text);
         $text->type = Mime\Mime::TYPE_TEXT;
         $text->charset = 'utf-8';
         $fileContent = fopen($filepath, 'r');
         $attachment = new Mime\Part($fileContent);
         $attachment->type = 'application/pdf';
         $attachment->filename = $candidateName;
         $attachment->disposition = Mime\Mime::DISPOSITION_ATTACHMENT;
         // Setting the encoding is recommended for binary data
         $attachment->encoding = Mime\Mime::ENCODING_BASE64;
         // then add them to a MIME message
         $mimeMessage = new Mime\Message();
         $mimeMessage->setParts(array($text, $attachment));
         // and finally we create the actual email
         $message = new Message();
         $message->setBody($mimeMessage);
         $message->setFrom($sender);
         $message->addTo($recipient);
         $message->setSubject($subject);
         // Send E-mail message
         $transport = new Sendmail('-f' . $sender);
         $transport->send($message);
         $result = true;
     } catch (\Exception $e) {
         $result = false;
     }
     // Return status
     return $result;
 }
Exemple #18
0
 private function sendEmail(array $listaEmailTo, array $listaEmailCC, $subject, $msg)
 {
     $renderer = $this->getServiceLocator()->get('ViewRenderer');
     $content = $renderer->render('email/template', array('msg' => nl2br($msg)));
     // make a header as html(template)
     $html = new MimePart($content);
     $html->type = "text/html";
     // make a image inline
     $image = new MimePart(fopen(__DIR__ . '\\..\\..\\..\\..\\Frota\\view\\email\\fundo_email_checkin.png', 'r'));
     $image->type = "image/jpeg";
     $image->id = "fundo_mail";
     $image->disposition = "inline";
     // build an email with a text(html) + image(inline)
     $body = new MimeMessage();
     $body->setParts(array($html, $image));
     // instance mail
     $mail = new Mail\Message();
     $mail->setBody($body);
     // will generate our code html from template.phtml
     $mail->setFrom($this->from['email'], utf8_decode($this->from['nome']));
     $mail->addTo($listaEmailTo);
     //$mail->addCc($listaEmailCC);
     $mail->setSubject(utf8_decode($subject));
     $transport = new Mail\Transport\Smtp($this->options);
     try {
         $transport->send($mail);
     } catch (RuntimeException $exc) {
         $this->logger->info('Erro ao enviar email para: ' . implode(',', $listaEmailTo) . ' erro: ' . $exc->getMessage() . "\n" . $exc->getTraceAsString());
         if ($exc->getMessage() == 'Could not open socket') {
             throw new Exception('O serviço de e-mail do MPM está indisponível no momento, a mensagem não foi enviada!');
         }
         throw new Exception("Não foi possível enviar a mensagem, ocorreu o seguinte erro: {$exc->getMessage()}!");
     }
 }
Exemple #19
0
 /**
  * Send contact mail
  * @param $controller
  * @param $data
  */
 public static function sendContactMail($controller, $data)
 {
     // prepare html content
     $comments = nl2br($data['comments']);
     // line break
     $content = '';
     $content .= '<table>';
     $content .= '<tbody>';
     $content .= "<tr><td>First Name:</td><td>{$data['firstName']}</td></tr>";
     $content .= "<tr><td>Last Name:</td><td>{$data['lastName']}</td></tr>";
     $content .= "<tr><td>Phone Number:</td><td>{$data['phone']}</td></tr>";
     $content .= "<tr><td>Email:</td><td>{$data['email']}</td></tr>";
     $content .= "<tr><td>Company:</td><td>{$data['company']}</td></tr>";
     $content .= "<tr><td>Job Title:</td><td>{$data['jobTitle']}</td></tr>";
     $content .= "<tr><td>Comments:</td><td>{$comments}</td></tr>";
     $content .= '</tbody>';
     $content .= '</table>';
     $html = new MimePart($content);
     $html->type = "text/html";
     $body = new MimeMessage();
     $body->setParts(array($html));
     $message = new Message();
     $message->setBody($body);
     // subject
     $subject = 'Contact from Papertask';
     $message->setSubject($subject);
     // get transport
     $transport = $controller->getServiceLocator()->get('mail.transport');
     $message->addTo($transport->mailOptions['contact']);
     $message->addFrom($transport->mailOptions['contact']);
     $transport->send($message);
 }
 /**
  * @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;
 }
 protected function sendEmailAction()
 {
     $userTable = $this->getServiceLocator()->get('UserTable');
     if (true) {
         //$this->request->isPost()) {
         $subject = 'subject';
         //$this->request->getPost()->get('subject');
         $body = 'body';
         //$this->request->getPost()->get('body');
         $fromUserId = 1;
         //$this->user->id;
         $toUserId = 2;
         //$this->request->getPost()->get('toUserId');
         $fromUser = $userTable->getUser($fromUserId);
         $toUser = $userTable->getUser($toUserId);
         $mail = new Mail\Message();
         $mail->setFrom($fromUser->email, $fromUser->name);
         $mail->addTo($toUser->email, $toUser->name);
         $mail->setSubject($subject);
         $mail->setBody($body);
         $transport = new Mail\Transport\Sendmail();
         $transport->send($mail);
     }
     return true;
 }
 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);
 }
Exemple #23
0
 public function sendInvoiceWithParams(Invoice $invoice, Parameters $data)
 {
     $message = new Message();
     $message->setTo($data->to);
     $message->setFrom($data->from);
     $message->setSubject($data->header);
     $message->setBody($data->content);
     $parts[] = $this->getAttachment($data->file, $data->fileName);
     $this->send($data->transport, $message, $parts);
 }
 /**
  * Dispara um e-mail conforme as configurações fornecidas.
  *
  * @param string $name    Nome do remetente
  * @param string $email   E-mail do remetente
  * @param string $subject Assunto do e-mail
  * @param string $message Conteúdo a ser enviado
  */
 public function sendEmail($name, $email, $subject, $message)
 {
     $mail = new Mail\Message();
     $mail->addTo($email, $name);
     $mail->setFrom('*****@*****.**', 'MPRecruiter');
     $mail->setSubject($subject);
     $mail->setBody($message);
     $transport = new Mail\Transport\Sendmail();
     $transport->send($mail);
 }
 public function sendAccountDeletionMail($email, $username, $token, $projectName)
 {
     $translator = $this->getTranslator();
     $mail = new MailMessage();
     $mail->setSubject(sprintf($translator->translate('confirm.account.deletion.at.%s'), $projectName));
     $this->addTarget($email, $username);
     $viewVariables = ['projectName' => $projectName, 'username' => $username, 'token' => $token];
     $this->prepareMail($mail, $viewVariables, 'mail/confirm-account-deletion.phtml');
     $this->sendMail($mail);
 }
Exemple #26
0
 public function sendMail($from, $name, $message)
 {
     $mail = new Message();
     $mail->setBody($message);
     $mail->setFrom($from, $name);
     $mail->setTo(self::EMAIL_ADMIN, 'Their name');
     $mail->setSubject('Test Subject');
     //Todo config le smtp
     //        $transport = new Transport\Sendmail();
     //        $transport->send($mail);
 }
 /**
  * @param TodoAssigneeWasReminded $event
  */
 public function __invoke(TodoAssigneeWasReminded $event)
 {
     $user = $this->userFinder->findById($event->userId()->toString());
     $todo = $this->todoFinder->findById($event->todoId()->toString());
     $mail = new Mail\Message();
     $mail->setBody("Hello {$user->name}. This a reminder for '{$todo->text}'. Don't be lazy!");
     $mail->setFrom('*****@*****.**', 'Proophessor-do');
     $mail->addTo($user->email, $user->name);
     $mail->setSubject('Proophessor-do Todo Reminder');
     $this->mailer->send($mail);
 }
Exemple #28
0
 public function testRestoreFromSerializedString()
 {
     $this->message->addTo('*****@*****.**', 'ZF DevTeam');
     $this->message->addFrom('*****@*****.**', "Matthew Weier O'Phinney");
     $this->message->addCc('*****@*****.**', 'ZF Contributors List');
     $this->message->setSubject('This is a subject');
     $this->message->setBody('foo');
     $serialized = $this->message->toString();
     $restoredMessage = Message::fromString($serialized);
     $this->assertEquals($serialized, $restoredMessage->toString());
 }
 /**
  * Search POSTED user email, send email with request to regenerate password or choose a new one
  *
  * @return mixed
  */
 public function sendrecoverrequestAction()
 {
     /**
      * @var \Doctrine\ORM\EntityManager $em
      */
     $em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
     $request = $this->getRequest();
     if (!$request->isPost()) {
         return $this->redirect()->toRoute('main');
     }
     $post = $request->getPost()->toArray();
     $inputFilter = new RecoverPasswordFormInputFilter();
     $form = new RecoverPasswordForm();
     $form->setInputFilter($inputFilter->getInputFilter());
     $form->setData($post);
     $helper = new UsersControllerHelper();
     $helper->setConnection($em->getConnection());
     if ($form->isValid()) {
         $userRecords = $helper->recoverWrapperRecords(new UsersGetterWrapper(new UsersGetter($em)), array('emailUsername' => $post['email'], 'limit' => 1));
         if (!empty($userRecords) and count($userRecords) == 1) {
             $confirmCode = md5(uniqid());
             $helper->updateConfirmCode($userRecords[0]['id'], $confirmCode);
             $uri = $request->getUri();
             $basePath = sprintf('%s://%s%s', $uri->getScheme(), $uri->getHost(), '');
             $linkRecoverPasswordForm = $basePath . $this->url()->fromRoute('recover-password', array('action' => 'formchangepassword', 'confirmcode' => $confirmCode));
             $appServiceLoader = $this->recoverAppServiceLoader(1);
             $configurations = $appServiceLoader->recoverService('configurations');
             $noReplayMail = isset($configurations['mailnoreply']) ? $configurations['mailnoreply'] : '*****@*****.**';
             $message = $configurations['sitename'] . "\n\n";
             $message .= "E' stata registrata una richiesta di recupero password per il sito in oggetto.\n\n";
             $message .= 'Per scegliere una nuova password, <a href="' . $linkRecoverPasswordForm . '">clicca qui</a>' . "\n\n";
             $message .= "Se non vedi il link, conferma la richiesta copiando e incollando il link sotto riportato sul tuo browser:\n\n";
             $message .= $linkRecoverPasswordForm . "\n\n";
             $message .= 'Non rispondere a questo messaggio' . "\n\n";
             $message .= date("Y") . ' ' . $configurations['sitename'];
             /* Send email with link for password recover */
             $mail = new Mail\Message();
             $mail->setBody($message);
             $mail->setFrom($noReplayMail, $configurations['sitename']);
             $mail->addTo($userRecords[0]['email'], $userRecords[0]['name'] . ' ' . $userRecords[0]['surname']);
             $mail->setSubject('Richiesta recupero password ', $configurations['sitename']);
             $transport = new Mail\Transport\Sendmail($userRecords[0]['email']);
             $transport->send($mail);
             /* Redirect to another page with OK message to avoid double POSTs */
             return $this->redirect()->toRoute('recover-password', array('action' => 'showconfirm', 'confirmcode' => 'passwordRequestSentOk'));
         } else {
             // User not found, invalid request...
         }
     } else {
         // The form is not valid, it can redirect to a confirm message page
     }
     return $this->redirect()->toRoute('main');
 }
Exemple #30
0
 /**
  * Send password lost email.
  *
  * @param NewUserModel $activation
  * @param MemberModel $member
  */
 public function sendPasswordLostMail(NewUserModel $newUser, MemberModel $member)
 {
     $body = $this->render('user/email/reset', ['user' => $newUser, 'member' => $member]);
     $translator = $this->getServiceManager()->get('translator');
     $message = new Message();
     $config = $this->getConfig();
     $message->addFrom($config['from']);
     $message->addTo($newUser->getEmail());
     $message->setSubject($translator->translate('Password reset code for the GEWIS Website'));
     $message->setBody($body);
     $this->getTransport()->send($message);
 }