Ejemplo n.º 1
0
 private function composeMail($from, $to, $subject)
 {
     $this->mail = new Message();
     $this->mail->setFrom($from)->setSubject($subject);
     $this->processFromEmail($from)->processToEmail($to);
     return $this->mail;
 }
Ejemplo n.º 2
0
 /**
  * @param string $email
  * @param string $name
  */
 public function setFrom($email, $name = null)
 {
     try {
         $this->message->setFrom($email, $name);
     } catch (\Exception $e) {
         throw new MailerException($e->getMessage());
     }
 }
Ejemplo n.º 3
0
 /** Funkcia pre odoslanie emailu
  * @param array $params Parametre správy
  * @param string $subjekt Subjekt emailu
  * @return string Zoznam komu bol odoslany email
  * @throws SendException
  */
 public function send($params, $subjekt)
 {
     $templ = new Latte\Engine();
     $this->mail->setFrom($params["site_name"] . ' <' . $this->from . '>');
     $this->mail->setSubject($subjekt)->setHtmlBody($templ->renderToString($this->template, $params));
     try {
         $sendmail = new SendmailMailer();
         $sendmail->send($this->mail);
         return $this->email_list;
     } catch (Exception $e) {
         throw new SendException('Došlo k chybe pri odosielaní e-mailu. Skúste neskôr znovu...' . $e->getMessage());
     }
 }
Ejemplo n.º 4
0
 /**
  * Vytvoří novou zprávu jakožto objekt \Nette\Mail\Message.
  * @see \Nette\Mail\Message
  * @param string|array $to Příjemce zprávy. Víc příjemců může být předáno jako pole.
  * @param string $subject Předmět zprávy.
  * @param string $message Předmět zprávy, nastavuje se přes setHtmlBody, tudíž lze předat výstup šablony.
  */
 public function createMessage($to, $subject, $message)
 {
     $this->message = new \Nette\Mail\Message();
     $this->message->setFrom($this->from);
     if (is_array($to)) {
         foreach ($to as $recipient) {
             $this->message->addTo($recipient);
         }
     } else {
         $this->message->addTo($to);
     }
     $this->message->setSubject($subject);
     $this->message->setHtmlBody($message);
 }
 /**
  * Callback for ForgottenPasswordForm onSuccess event.
  * @param Form      $form
  * @param ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     $user = $this->userManager->findByEmail($values->email);
     if (!$user) {
         $form->addError('No user with given email found');
         return;
     }
     $password = Nette\Utils\Random::generate(10);
     $this->userManager->setNewPassword($user->id, $password);
     try {
         // !!! Never send passwords through email !!!
         // This is only for demonstration purposes of Notejam.
         // Ideally, you can create a unique link where user can change his password
         // himself for limited amount of time, and then send the link.
         $mail = new Nette\Mail\Message();
         $mail->setFrom('*****@*****.**', 'Notejamapp');
         $mail->addTo($user->email);
         $mail->setSubject('New notejam password');
         $mail->setBody(sprintf('Your new password: %s', $password));
         $this->mailer->send($mail);
     } catch (Nette\Mail\SendException $e) {
         Debugger::log($e, Debugger::EXCEPTION);
         $form->addError('Could not send email with new password');
     }
 }
Ejemplo n.º 6
0
 public function onFinish()
 {
     if (!count($this->messages)) {
         return;
     }
     // everything went alright
     $contents = implode(PHP_EOL, $this->messages) . PHP_EOL;
     // Only write the |$contents| to the file when this is not ran as part of a unit test.
     // Ideally we would verify that the write was successful, but there's no good fallback.
     if (!$this->isTest) {
         file_put_contents(self::ERROR_LOG, $contents, FILE_APPEND);
     }
     // Early-return if there are no failures, because there is no need to send an alert message
     // for successful service execution.
     if ($this->failures == 0) {
         return;
     }
     $configuration = Configuration::getInstance();
     // E-mail alerts can be disabled by the configuration, but force-enable them for tests.
     if (!$configuration->get('serviceLog/alerts') && !$this->isTest) {
         return;
     }
     // Compose an e-mail message for sending out an alert message. The recipients of this
     // message are defined in the main configuration file.
     $alert = new Message();
     $alert->setFrom($configuration->get('serviceLog/from'))->setSubject($configuration->get('serviceLog/subject'))->setBody($contents);
     foreach ($configuration->get('serviceLog/recipients') as $recipient) {
         $alert->addTo($recipient);
     }
     $this->mailer->send($alert);
 }
Ejemplo n.º 7
0
 public function sendMail($formValues)
 {
     //        dump($formValues);
     //        die();
     //
     $template = new Nette\Templating\FileTemplate(__DIR__ . '/emailTemplates/' . $this->templateFilename);
     $template->registerFilter(new Nette\Latte\Engine());
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     $attachments = array();
     if (isset($formValues['cv']) && $formValues['cv'] instanceof Nette\Http\FileUpload) {
         if ($formValues['cv']->isOk()) {
             $attachments[$formValues['cv']->getName()] = $formValues['cv']->getContents();
         }
     }
     unset($formValues['cv']);
     $template->values = $formValues;
     //        echo $template;
     //        die();
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->from)->setSubject($this->subject)->addTo($this->to)->setHtmlBody($template);
     if ($attachments) {
         foreach ($attachments as $name => $content) {
             $mail->addAttachment($name, $content);
         }
     }
     //        foreach ($tos as $to) {
     //            $mail->addTo($to);
     //        }
     $mail->send();
 }
Ejemplo n.º 8
0
 /**
  *
  * @return Message 
  */
 private function prepareMessage()
 {
     $message = new Message();
     $message->setFrom($this->from, $this->fromName);
     $message->setMailer($this->mailer);
     return $message;
 }
Ejemplo n.º 9
0
 function orderFormSucceeded(Form $form, $values)
 {
     $user = $this->findUser();
     $order = new Order($user);
     $order->setType($values->type);
     $order->setAmount($values->amount);
     $order->setName($values->name);
     $order->setPhone($values->phone);
     $order->setBusinessName($values->business_name);
     $order->setIc($values->ic);
     $order->setDic($values->dic);
     $order->setAddress($values->address);
     $order->setInvoiceAddress($values->invoice_address);
     $order->setShippingMethod($values->shipping_method);
     $order->setNote($values->note);
     $price_index = $values->type . '.price_per_unit';
     $order->setPricePerUnit(Settings::get($price_index));
     $this->em->persist($order);
     $this->em->flush();
     $order->createNum();
     $this->em->flush();
     $this->orderManager->invoice($order, true);
     $mail = new Message();
     $mail->setFrom(Settings::get('contact.name') . ' <' . Settings::get('contact.email') . '>')->addTo($order->getUser()->getEmail())->setSubject('Your order ' . $order->getNum())->setBody('You have placed a new order on kryo.mossbauer.cz. Please follow payment instructions in attachment.');
     $mail->addAttachment(WWW_DIR . '/../temp/' . $order->getInvoiceFileName());
     $this->mailer->send($mail);
     $this->flashMessage('Order has been successfully created!', 'success');
     $this->redirect('this');
 }
 /**
  * Callback method, that is called once form is successfully submitted, without validation errors.
  *
  * @param Form $form
  * @param Nette\Utils\ArrayHash $values
  */
 public function formSucceeded(Form $form, $values)
 {
     if (!($user = $this->userRepository->findOneBy(['email' => $values->email]))) {
         $form['email']->addError("User with given email doesn't exist");
         return;
     }
     // this is not a very secure way of getting new password
     // but it's the same way the symfony app is doing it...
     $newPassword = $user->generateRandomPassword();
     $this->em->flush();
     try {
         $message = new Nette\Mail\Message();
         $message->setSubject('Notejam password');
         $message->setFrom('*****@*****.**');
         $message->addTo($user->getEmail());
         // !!! Never send passwords through email !!!
         // This is only for demonstration purposes of Notejam.
         // Ideally, you can create a unique link where user can change his password
         // himself for limited amount of time, and then send the link.
         $message->setBody("Your new password is {$newPassword}");
         $this->mailer->send($message);
     } catch (Nette\Mail\SendException $e) {
         Debugger::log($e, 'email');
         $form->addError('Could not send email with new password');
     }
     $this->onSuccess($this);
 }
Ejemplo n.º 11
0
 /**
  * @param string $senderEmail
  * @param string $recipientEmail
  * @param callable $templateCallback
  * @param array $param
  * @throws InvalidStateException
  */
 public function send($senderEmail, $recipientEmail, callable $templateCallback, array $param = [])
 {
     $template = $this->prepareTemplate($templateCallback, $param);
     $mail = new Message();
     $mail->setFrom($senderEmail)->addTo($recipientEmail)->setHtmlBody($template);
     $this->mailer->send($mail);
 }
 public function buyFormSucceeded(\CustomForm $form, $values)
 {
     $product = $this->context->moduleSimpleEshopModel->getProduct($this->getParameter("id"), 1);
     $this->iModuleId = $product["page_page_modules_id"];
     $this->loadModuleFromDB();
     if ($form->isValid()) {
         $values["product_id"] = $product["id"];
         $values["product_title"] = $product["title"];
         $values["page_page_modules_id"] = $product["page_page_modules_id"];
         $order = $this->db->createOrder($values);
         if (!$order) {
             $this->flashMessage('Jejda. :( Něco je špatně. Zkuste znovu nebo se s námi spojte přímo. Děkujeme za pochopení.');
         } else {
             $mail = new Message();
             $mailer = new SendmailMailer();
             $emailHTML = $this->getEmailHTML($order, $product);
             // send confirmation email to customer
             $mail->setFrom($this->module->settings->email)->addTo($order->email)->setSubject('Potvrzení o koupi.')->setHTMLBody($emailHTML);
             $mailer->send($mail);
             // send confirmation email to owner of the eshop
             $mail->setFrom($this->module->settings->email)->addTo($this->module->settings->email)->setSubject('Potvrzení o koupi.')->setHTMLBody($emailHTML);
             $mailer->send($mail);
             $this->flashMessage($this->module->settings->order_confirmation, 'success');
         }
     } else {
         $this->flashMessage('Doplňte prosím všechny povinné položky.');
     }
     $this->redirect(":" . $this->getName() . ':Product', array('id' => $product['nice_url_segment'], 'moduleid' => $product['page_page_modules_id']));
 }
Ejemplo n.º 13
0
 /**
  * @param string $user
  * @param string $name
  * @param string $type
  * @param string $action
  * @param mixed[] $templateArgs
  */
 public function send($user, $name, $type, $action, array $templateArgs = array())
 {
     $presenter = $this->createPresenter();
     $request = $this->getRequest($type, $action);
     $response = $presenter->run($request);
     $presenter->template->user = $user;
     $presenter->template->name = $name;
     foreach ($templateArgs as $key => $val) {
         $presenter->template->{$key} = $val;
     }
     if (!$response instanceof TextResponse) {
         throw new InvalidArgumentException(sprintf('Type \'%s\' does not exist.', $type));
     }
     try {
         $data = (string) $response->getSource();
     } catch (\Nette\Application\BadRequestException $e) {
         if (Strings::startsWith($e->getMessage(), 'Page not found. Missing template')) {
             throw new InvalidArgumentException(sprintf('Type \'%s\' does not exist.', $type));
         }
     }
     $message = new Message();
     $message->setHtmlBody($data);
     $message->setSubject(ucfirst($action));
     $message->setFrom($this->senderEmail, $this->senderName ?: null);
     $message->addTo($user, $name);
     $this->mailer->send($message);
 }
Ejemplo n.º 14
0
 public function send($from, $to, $subject, $template)
 {
     $mail = new Message();
     $mail->setFrom($from)->addTo($to)->setSubject($subject)->setHTMLBody($template);
     $mailer = new SendmailMailer();
     $mailer->send($mail);
 }
Ejemplo n.º 15
0
 public function sendMailConsumer(\PhpAmqpLib\Message\AMQPMessage $message)
 {
     $sendMail = json_decode($message->body);
     $latte = new Latte\Engine();
     $sendMail->templateArr->email = $sendMail->to;
     $sendMail->templateArr->subject = $sendMail->subject;
     if (!is_null($sendMail->unsubscribeLink)) {
         $sendMail->templateArr->unsubscribeLink = $sendMail->unsubscribeLink;
     }
     $mail = new Nette\Mail\Message();
     $mail->setFrom($sendMail->from)->addTo($sendMail->to)->setHtmlBody($latte->renderToString($this->config["appDir"] . $this->config['mailer']['templateDir'] . (is_null($sendMail->template) ? $this->config['mailer']['defaultTemplate'] : $sendMail->template), (array) $sendMail->templateArr));
     if (!is_null($sendMail->unsubscribeEmail) || !is_null($sendMail->unsubscribeLink)) {
         $mail->setHeader('List-Unsubscribe', (!is_null($sendMail->unsubscribeEmail) ? '<mailto:' . $sendMail->unsubscribeEmail . '>' : '') . (!is_null($sendMail->unsubscribeEmail) && !is_null($sendMail->unsubscribeLink) ? ", " : "") . (!is_null($sendMail->unsubscribeLink) ? '<' . $sendMail->unsubscribeLink . '>' : ''), TRUE);
     }
     $mail->setSubject($sendMail->subject);
     try {
         $mailer = $this->emailFactory->getConnection($sendMail->connection);
         $mailer->send($mail);
         dump($sendMail->to);
         if ($sendMail->imapSave) {
             $this->saveToImap($mail->generateMessage(), is_null($sendMail->imapFolder) ? $this->config['imap']['sendFolder'] : $sendMail->imapFolder, $sendMail->imapConnection);
         }
         return TRUE;
     } catch (\Exception $e) {
         return FALSE;
     }
 }
Ejemplo n.º 16
0
 public function nette($from, $email, $subject, $content)
 {
     $mail = new Message();
     $mail->setFrom($from)->addTo($email)->setSubject($subject)->setHtmlBody($content);
     $mailer = new Nette\Mail\SmtpMailer(array('host' => getenv('NETTE_EMAIL_HOST') ?: '', 'smtp_port' => getenv('NETTE_EMAIL_PORT') ?: '25', 'username' => getenv('NETTE_EMAIL_USERNAME') ?: '', 'password' => getenv('NETTE_EMAIL_PASSWORD') ?: '', 'secure' => getenv('NETTE_EMAIL_SECURE') ?: 'ssl'));
     $mailer->send($mail);
 }
Ejemplo n.º 17
0
 public function sendEmail($from, $to, $template)
 {
     $mail = new Message();
     $mail->setFrom($from)->addTo($to)->setSubject($template->subject)->setHtmlBody($template->body);
     // dump($from); dump($to); dump($template); exit;
     $mailer = new SendmailMailer();
     $mailer->send($mail);
 }
Ejemplo n.º 18
0
 /**
  * @param int $id
  */
 public function notifyByEmail($id)
 {
     $ne = $this->getNotifyEmailById($id);
     $mail = new Message();
     $mail->setFrom("Wifimapa <*****@*****.**>")->addTo($ne["email"])->setSubject('Potvrzení získání dat')->setBody("Dobrý den,\ndata o která jste požádal byla získána do databáze.");
     $mailer = new SendmailMailer();
     $mailer->send($mail);
 }
Ejemplo n.º 19
0
 /**
  * @param string $email address
  * @param string $name
  * @throws Exception
  */
 public function sendBootstrap($email, $name)
 {
     $msg = new Message();
     $latte = new Engine();
     $args = ['email' => $msg];
     $html = $latte->renderToString($this->getTemplatePath('bootstrap'), $args);
     $msg->setFrom('*****@*****.**', 'Application Name')->addTo($email, $name)->setHtmlBody($html);
     $this->mailer->send($msg);
 }
Ejemplo n.º 20
0
 /**
  * Mail message factory
  *
  * @return Nette\Mail\Message
  */
 protected function createMessage()
 {
     $message = new Nette\Mail\Message();
     // CLI
     if ($this->context->httpRequest->getUrl()->getHost() != "") {
         $message->setFrom('info@' . $this->context->httpRequest->getUrl()->getHost());
     }
     return $message;
 }
Ejemplo n.º 21
0
    public function sendReservationMail($reservation)
    {
        $mail = new Message();
        $mail->setFrom(SELF::FROM)->addTo($reservation['userEmail'])->addBcc(SELF::DEMEL)->setHtmlBody('<p>Dobrý den,
                            Rezervace u MCPneu proběhla v pořádku. Podrobnosti rezervace naleznete níže.</p>



                            <p>Těšíme se na Vaši návštěvu.</p>');
    }
Ejemplo n.º 22
0
 public function emailFormSucceeded(Form $form, $values)
 {
     $settings = $this->EntityManager->getRepository(Settings::getClassName());
     $setting = $settings->find(1);
     $mail = new Message();
     $mail->setFrom($values['email'])->addTo($setting->admin_email)->setSubject('Zpráva z webu PeTr - ' . $values['subject'])->setBody('Zpráva od ' . $values['name'] . '<br /><br />' . $values['message']);
     $mailer = new SendmailMailer();
     //$mailer->send($mail);
     $this->redirect('Contact:sent');
 }
Ejemplo n.º 23
0
 public function sendKontaktMail($clovekMail, $clovekName, $zprava, $spravci)
 {
     $mail = new Message();
     $mail->setFrom($this->mailerFromAddress)->setSubject('Nová zpráva z konktaktního formuláře webu SVJ Čiklova 647/3')->addReplyTo($clovekMail)->setBody($clovekName . " s emailem " . $clovekMail . " posílá následující dotaz: \n\n" . $zprava);
     foreach ($spravci as $address) {
         $mail->addTo($address);
     }
     $this->mailer->send($mail);
     return 1;
 }
Ejemplo n.º 24
0
 public function formContactSubmitted(Nette\Application\UI\Form $form)
 {
     $fd = $form->getValues();
     $latte = new \Latte\Engine();
     $params = array('text' => $fd->text);
     $mail = new Nette\Mail\Message();
     $mail->setFrom($fd->email)->addTo('*****@*****.**')->setSubject('Svatba ' . $fd->phone)->setHtmlBody($latte->renderToString('../app/presenters/templates/mail.latte', $params));
     $this->mailer->send($mail);
     $this->flashMessage("Email byl odeslán. Ozveme se :-)", "success");
     $this->redirect("this");
 }
Ejemplo n.º 25
0
 /**
  * @return Mail\Message
  */
 public function create()
 {
     $message = new Mail\Message();
     if ($this->from) {
         $message->setFrom($this->from);
     }
     if ($this->returnPath) {
         $message->setReturnPath($this->returnPath);
     }
     return $message;
 }
 /**
  * @param Nette\Application\UI\Form $form
  */
 public function contactFormSubmitted(Nette\Application\UI\Form $form)
 {
     $values = $form->getValues();
     if ($this->context->getParameters()["send_emails"]) {
         $latte = new Engine();
         $mail = new Message();
         $mail->setFrom($this->context->getParameters()["mailer_mail"])->addTo($this->context->getParameters()["mailer_mail"])->setHtmlBody($latte->renderToString(__DIR__ . '/templates/Contact/email.latte', array("email" => $values->email, "content" => $values->content)));
         $mailer = new Nette\Mail\SmtpMailer(array('host' => $this->context->getParameters()["mailer_host"], 'username' => $this->context->getParameters()["mailer_mail"], 'password' => $this->context->getParameters()["mailer_password"], 'secure' => 'ssl'));
         $mailer->send($mail);
     }
     $this->redirect("Contact:sent");
 }
Ejemplo n.º 27
0
 /**
  * @param string $subject
  * @param string $messageText
  * @throws \Nette\InvalidStateException
  */
 private function sendMail($subject, $messageText, $attachedFile = null)
 {
     $message = new Message();
     $message->setFrom('Výčetkový systém <' . $this->emails['system'] . '>')->addTo($this->emails['admin'])->setSubject($subject)->setBody($messageText);
     if ($attachedFile !== null and file_exists($attachedFile)) {
         $message->addAttachment($attachedFile);
     }
     try {
         $this->mailer->send($message);
     } catch (InvalidArgumentException $is) {
         $this->logError($is->getMessage());
     }
 }
Ejemplo n.º 28
0
 /**
  * Odesila email pres PHP nastaveni
  * @param string $from
  * @param string | array $to
  * @param string $body
  * @param string $subject
  */
 private function sendMail($from, $to, $body, $subject)
 {
     $mail = new Message();
     $mail->setFrom($from)->setSubject($subject)->setHtmlBody($body);
     if (is_array($to)) {
         foreach ($to as $toItem) {
             $mail->addTo($toItem);
         }
     } else {
         $mail->addTo($to);
     }
     $this->appMailer->send($mail);
 }
Ejemplo n.º 29
0
 public function generateMessage(Reciever $reciever, ContentConfig $contentConfig)
 {
     $message = new Message();
     $message->setFrom($this->sender->getEmail(), $this->sender->getName());
     $message->setBody($contentConfig->getContent($reciever));
     $message->setSubject($contentConfig->getSubject());
     $message->addTo($reciever->getEmail(), $reciever->getFullName());
     $message->addBcc($this->sender->getEmail());
     foreach ($contentConfig->getAttachments() as $attachment) {
         $message->addAttachment($attachment);
     }
     return $message;
 }
Ejemplo n.º 30
0
 function handleFulfill($id)
 {
     /** @var Order $order */
     $order = $this->em->find(Order::class, $id);
     if ($order) {
         $this->orderManager->changeStatus($order, Order::STATUS_FULFILLED);
         $mail = new Message();
         $mail->setFrom(Settings::get('contact.name') . ' <' . Settings::get('contact.email') . '>')->addTo($order->getUser()->getEmail())->setSubject('Order ' . $order->getNum() . ' ready')->setBody('Your order is ready to be shipped / ready for pick up.');
         $this->mailer->send($mail);
         $this->flashMessage("Order {$order->getNum()} fulfilled", 'info');
         $this->redirect('this');
     }
 }