Exemplo n.º 1
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()}!");
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
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);
     //发送消息
 }
Exemplo n.º 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);
 }
 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;
 }
Exemplo n.º 7
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
     }
 }
 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()]);
 }
Exemplo n.º 9
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);
 }
Exemplo n.º 10
0
 function send($recipients, $type = 'mail')
 {
     global $tikilib, $prefs;
     $logslib = TikiLib::lib('logs');
     $this->mail->getHeaders()->removeHeader('to');
     foreach ((array) $recipients as $to) {
         $this->mail->addTo($to);
     }
     if ($prefs['zend_mail_handler'] == 'smtp' && $prefs['zend_mail_queue'] == 'y') {
         $query = "INSERT INTO `tiki_mail_queue` (message) VALUES (?)";
         $bindvars = array(serialize($this->mail));
         $tikilib->query($query, $bindvars, -1, 0);
         $title = 'mail';
     } else {
         try {
             tiki_send_email($this->mail);
             $title = 'mail';
         } catch (Zend\Mail\Exception\ExceptionInterface $e) {
             $title = 'mail error';
         }
         if ($title == 'mail error' || $prefs['log_mail'] == 'y') {
             foreach ($recipients as $u) {
                 $logslib->add_log($title, $u . '/' . $this->mail->getSubject());
             }
         }
     }
     return $title == 'mail';
 }
 /**
  * @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;
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
 /**
  * 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;
 }
 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;
 }
Exemplo n.º 15
0
 public function sendMessage(Message $message, Smtp $smtp, $recipient)
 {
     $message->addTo($recipient);
     if (!$this->config['disable_delivery']) {
         $smtp->send($message);
     }
 }
Exemplo n.º 16
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);
     }
 }
Exemplo n.º 17
0
 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;
 }
 /**
  * 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));
 }
Exemplo n.º 19
0
 public function run()
 {
     $transport = new SmtpTransport(new SmtpOptions(array('name' => $this->host, 'host' => $this->host, 'port' => $this->port, 'connection_config' => array('username' => $this->sender->getUsername(), 'password' => $this->sender->getPassword()))));
     if ($this->auth !== null) {
         $transport->getOptions()->setConnectionClass($this->auth);
     }
     $message = new Message();
     $message->addFrom($this->sender->getUsername())->setSubject($this->subject);
     if ($this->bcc) {
         $message->addBcc($this->recipients);
     } else {
         $message->addTo($this->recipients);
     }
     $body = new MimeMessage();
     if ($this->htmlBody == null) {
         $text = new MimePart($this->textBody);
         $text->type = "text/plain";
         $body->setParts(array($text));
     } else {
         $html = new MimePart($this->htmlBody);
         $html->type = "text/html";
         $body->setParts(array($html));
     }
     $message->setBody($body);
     $transport->send($message);
 }
Exemplo n.º 20
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);
    }
Exemplo n.º 21
0
 /**
  * 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;
         }
     }
 }
Exemplo n.º 22
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;
 }
Exemplo n.º 23
0
 /**
  * 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);
 }
Exemplo n.º 24
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);
 }
 /**
  * @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);
 }
Exemplo n.º 26
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());
 }
Exemplo n.º 27
0
 private function createMessage()
 {
     $message = new Message();
     $config = $this->config['message'];
     $message->addTo($config['to']);
     if ($config['from']) {
         $message->addFrom($config['from']);
     }
     $message->setSender($config['sender']['address'], $config['sender']['name']);
     return $message;
 }
Exemplo n.º 28
0
 /**
  * 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');
 }
Exemplo n.º 29
0
 /**
  * Send registration email.
  *
  * @param NewUserModel $newUser
  * @param MemberModel $member
  */
 public function sendRegisterEmail(NewUserModel $newUser, MemberModel $member)
 {
     $body = $this->render('user/email/register', array('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('Account activation code for the GEWIS Website'));
     $message->setBody($body);
     $this->getTransport()->send($message);
 }
Exemplo n.º 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);
 }