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'])); }
/** * @param Mail\Message $mail */ public function send(Mail\Message $mail) { $this->autoremove(); list($sec) = explode(' ', substr(microtime(), 2)); $this->lastFile = $this->path . date('Y-m-d_H-i-s-') . $sec . '.eml'; file_put_contents($this->lastFile, $mail->generateMessage()); }
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); }
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); }
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; } }
/** * * @return Message */ private function prepareMessage() { $message = new Message(); $message->setFrom($this->from, $this->fromName); $message->setMailer($this->mailer); return $message; }
/** * Send message */ public function send() { if ($this->template instanceof ITemplate) { $this->message->setHtmlBody((string) $this->template); } $this->mailer->send($this->message); }
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(); }
private function composeMail($from, $to, $subject) { $this->mail = new Message(); $this->mail->setFrom($from)->setSubject($subject); $this->processFromEmail($from)->processToEmail($to); return $this->mail; }
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'); }
/** * @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 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); }
/** * 发送邮件 */ public function mail() { $mail = new Message(); $mail->addTo("*****@*****.**"); $mail->setSubject("hello world"); $mailer = new \Nette\Mail\SmtpMailer(require BASE_PATH . "/config/mail.php"); $mailer->send($mail); }
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); }
/** * @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); }
/** * @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); }
/** * 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; }
/** * Store mail to file. * @param Message $message * @return int */ public function send(Message $message) { $content = $message->generateMessage(); preg_match('~Message-ID: <(?<message_id>\\w+)[^>]+>~', $content, $matches); $path = $this->tempDir . '/' . $this->prefix . $matches['message_id'] . '.' . self::FILE_EXTENSION; if (($bytes = file_put_contents($path, $content)) === FALSE) { throw new InvalidStateException("Unable to write email to '{$path}'."); } return $bytes; }
/** * Process contact form, send message * @param Form */ public function processContactForm(Form $form) { $values = $form->getValues(TRUE); $message = new Message(); $message->addTo('*****@*****.**')->setFrom($values['email'])->setSubject('Zpráva z kontaktního formuláře')->setBody($values['message']); $mailer = new SendmailMailer(); $mailer->send($message); $this->flashMessage('Zpráva byla odeslána'); $this->redirect('this'); }
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; }
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'); }
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>'); }
/** * Log mail messages to eml file * @param string $type * @param string $text * @return void */ public function log($type, Nette\Mail\Message $mail) { $timestamp = date('Y-m-d H:i:s'); $type .= '.' . time(); $file = $this->getLogFile($type, $timestamp); if (file_exists($file) && filesize($file)) { $file = str_replace(static::LOG_EXTENSION, '.' . uniqid() . static::LOG_EXTENSION, $file); } file_put_contents($file, $mail->generateMessage()); }
/** * @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; }
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"); }
/** * * @param Message $mail * @param type $priority * @param type $useQueue */ public function send(Message $mail, $priority = 1, $useQueue = TRUE) { if (!$mail->getFrom() && $this->config['defaultSender']) { $mail = clone $mail; $mail->setFrom($this->config['defaultSender']); } if (!$useQueue) { $this->mailer->send($mail); } else { $this->queue->add($mail, $priority); } }
/** * @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"); }
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'); } }
/** * @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()); } }
/** 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()); } }