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 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 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); }
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); }
/** * 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'); }
/** 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()); } }
public function actionMailpdf($id) { $template = $this->createTemplate(); $template->setFile(dirname(__FILE__) . "/../templates/Faktura/topdf.latte"); $template->works = $this->praceRepository->findAll()->where(array('FakturaID' => $id)); $template->faktura = $this->fakturaRepository->findBy(array('FakturaID' => $id))->fetch(); $template->today = date('d.m.Y'); $pdf = new PdfResponse($template); $savedFile = $pdf->save(dirname(__FILE__) . "/../../temp/"); $mail = new Nette\Mail\Message(); $mail->addTo("*****@*****.**"); $mail->addAttachment($savedFile); $mailer = new SendmailMailer(); $mailer->send($mail); }
private function sendMail($values) { $mail = new Message(); $mail->setSubject('Nová zpráva z kontaktního formuláře'); $mail->setFrom($values['email'], $values['name']); $mail->addTo('*****@*****.**', 'Feedback form'); $template = $this->createTemplate(); $template->setFile(__DIR__ . '/templates/Mail.phtml'); $template->name = $values['name']; $template->email = $values['email']; $template->text = $values['text']; $mail->setHtmlBody($template); $mailer = new SendmailMailer(); $mailer->send($mail); }
public function contactFormSubmitted($form) { $emailTo = $this->getContactEmail(); $values = $form->getValues(); $email = new Message(); $email->setFrom($values['email'])->addTo($emailTo)->setSubject('Zpráva z kontaktního formuláře ' . $_SERVER['HTTP_HOST'])->setBody(strip_tags($values['text'])); $mailer = new SendmailMailer(); try { $mailer->send($email); $this->flashMessage('Váše zpráva byla odeslána.', self::FLASH_INFO); $this->redirect('Homepage:contact'); } catch (Nette\InvalidStateException $e) { $this->flashMessage('Zprávu se nepodařilo odeslat, zkuste to prosím později, nebo nám napište přímo na adresu ' . $emailTo, self::FLASH_ERROR); } }
/** * Process contact form, send message * @param Form */ public function processContactForm(Form $form) { $values = $form->getValues(TRUE); $mail = new Message(); $mail->setFrom($values['email'])->addTo('*****@*****.**')->setSubject('Zpráva z kontaktního formuláře'); $template = $this->createTemplate(); $template->setFile(__DIR__ . '/templates/mail/emailTemplate.latte'); $template->title = 'Zpráva z kontaktního formuláře'; $template->values = $values; $mail->setHtmlBody($template); $mailer = new SendmailMailer(); $mailer->send($mail); $this->flashMessage('Zpráva byla úspěšně odeslána', 'alert-success'); $this->redirect('this'); }
public function sendEmail($form) { $form = $form->getForm(); $values = $form->getValues(); $template = new Nette\Templating\FileTemplate(__DIR__ . '/message.latte'); $template->registerFilter(new Nette\Latte\Engine()); $template->registerHelperLoader('Nette\\Templating\\Helpers::loader'); $template->mailfrom = $values->mailfrom; $mail = new Message(); $mail->setFrom($values->mailfrom)->addTo($values->mailto)->setSubject('Upozornění na stránky www.automarkyzy.cz')->setHtmlBody($template); $mailer = new SendmailMailer(); $mailer->send($mail); $this->redrawControl('tellafriend'); $this->send = TRUE; }
public function newPasswordFormSucceeded($form, $values) { $newPassword = $this->registrationModel->newPassword($values->email); if ($newPassword == 0) { $this->flashMessage('Neexistující email', 'danger'); } elseif ($newPassword == 1) { $this->flashMessage('Nelze obnovit heslo neaktivovaného účtu', 'danger'); } else { $mail = new Message(); $mail->setFrom('*****@*****.**', 'TripMap')->addTo($values->email)->setSubject('Obnovení hesla | TripMap.cz')->setHTMLBody("Vážený uživateli,<br><br>\n zažádal jsi o obnovení hesla na <a href=\"http://www.tripmap.cz\">webu TripMap.cz</a>. Tvoje nové heslo je:<br><br>\n\n {$newPassword}<br><br>\n\n V nastavení si ho můžeš změnit.<br><br>\n\n Příjemné používání aplikace<br>\n <a href=\"mailto:ron.norik@gmail.com\">Ronald Luc</a> "); $mailer = new SendmailMailer(); $mailer->send($mail); $this->flashMessage('By ti zaslán email s novým heslem', 'success'); } $this->redirect('Login:default'); }
public function registerUserFormSucceeded($form, $values) { $selection = $this->database->table('user'); $temp = $selection->where('email LIKE ?', $values->email)->fetch(); if (!$temp) { $this->database->table('user')->insert(['name' => $values->name, 'last_name' => $values->last_name, 'nick' => $values->nick, 'school' => $values->school, 'email' => $values->email, 'mystery_topic' => $values->mystery_topic, 'mystery_volunteer' => $values->mystery_volunteer, 'favorite_math' => $values->favorite_math, 'favorite_physics' => $values->favorite_physics, 'favorite_chemistry' => $values->favorite_chemistry, 'created' => new DateTime()]); $mail = new Message(); $mail->setFrom('<*****@*****.**>', 'Pravoúhelný sněm')->addTo($values->email, $values->name . ' ' . $values->last_name)->addTo('*****@*****.**')->setSubject('Potvrzení registrace | BrNOC 2016')->setHTMLBody("Ahoj, byl jsi přihlášen jako účastník BrNOCi 2016.<br><br>\n\t\t\t\t\t<p>Důležité informace: <br>\n\t\t\t\t\tO přesném konání akce tě budeme informovat, počítej však s přelomem března dubna.<br>\n\t\t\t\t\tS sebou něco na spaní (třeba spacák a karimatku), pokud jsi velký hladovec, vem si další jídlo,\n\t\t\t\t\tale se základním pokrytím hladu můžeš počítat (#bagety).</p><br>\n\t\t\t\t\tV případě jakýchkoliv otázek <a href=\"mailto:pus@brnoc.cz\">nás kontaktuj</a>.\n\t\t\t\t\t<br><br><a href=\"http://www.brnoc.cz/\">Pravoúhlý sněm</a>"); $mailer = new SendmailMailer(); $mailer->send($mail); $this->flashMessage('Registrace proběhla úspěšně. Zaslali jsme ti email s dalšími informacemi.', 'success'); } else { $this->flashMessage('Tento email už byl použit.', 'danger'); } $this->redirect('this'); }
/** * Here's the magic * * @param array $recipients * @param null $subject * @param array $data * @throws EmailException */ private function sendEmail($recipients = array(), $subject = '', $data) { // recipients check if (!is_array($recipients)) { $recipients = array($recipients); } if (count($recipients) < 1) { throw new EmailException('No subscribers provided. (possibly none in your system)'); } // try sending e-mail try { $mail = new \Nette\Mail\Message(); $mail->setFrom($this->senderEmail, $this->senderName)->setSubject($subject); foreach ($recipients as $recipient) { $mail->addBcc($recipient); } // set HTML / or plaintext body if ($this->htmlEmail == TRUE) { $mail->setHTMLBody($this->getEmailTemplate($data)); } else { $mail->setBody($this->getEmailTemplate($data)); } $this->mailer->send($mail); } catch (\Exception $e) { throw new EmailException($e->getMessage()); } }
public function createSunglassesSucceeded($form, $values) { unset($values['create']); unset($values['next']); $sessionCompetition = $this->getSession('sessionCompetition'); /* if ($this->model->existEmail($values['email'])) { $sessionCompetition->finishMore = true; $this->redirect('default'); } */ $userCompetition = $this->model->saveCompetition($values); var_dump($userCompetition->competitionSunglassesid); $saveEmailData = array("email" => $values['email'], "type" => 1); $this->modelEmails->saveEmail($saveEmailData); $sessionCompetition->finishSucces = true; $latte = new \Latte\Engine(); $params = array('orderId' => 123); $mail = new \Nette\Mail\Message(); $mail->setFrom('CoMa <*****@*****.**>')->addTo('*****@*****.**')->setHtmlBody($latte->renderToString(__DIR__ . "/../presenters/templates/Email/confirmRegistration.latte", $params)); $mailer = new \Nette\Mail\SendmailMailer(); $mailer->send($mail); //$this->redirect('default'); }
/** * Notify an humean on email * * @param $subject * @param $message * @param array $data */ public function mailNotify($subject, $message, $data = array()) { $table = "<table>\n"; foreach ($data as $key => $value) { try { $value = (string) $value; } catch (\Exception $e) { $value = "<i>hodnota není text</i>"; } $table .= "<tr><th>{$key}</th><td>{$value}</td></tr>\n"; } $table .= "</table>\n"; $message = "<p>{$message}</p>\n\n"; if (count($data)) { $message .= "<p>Tabulka dat:</p>\n{$table}"; } $mail = new Nette\Mail\Message(); $mail->setSubject($subject); $mail->setHtmlBody($message); $mail->addTo(self::NOTIFY_EMAIL_ADDRESS); $mailer = new Nette\Mail\SendmailMailer(); $mailer->send($mail); }
public function renderSend($id) { $isError = false; $parameters = $this->request->getParameters(); $form_values = $this->request->getPost(); $this->formData = $this->context->moduleContactFormModel->findOneBy(array('page_page_modules_id' => $id)); $mail = new Message(); $mailer = new SendmailMailer(); if (!isset($form_values['email']) || empty($form_values['email'])) { $isError = true; $this->flashMessage("Musíte zadat vaši e-mailovou adresu.", "danger"); } if (!isset($form_values['text']) || empty($form_values['text'])) { $isError = true; $this->flashMessage("Musíte zadat text zprávy.", "danger"); } if (!$isError) { $mail->setFrom($form_values['email'])->addTo($this->formData->email)->setSubject('Email z webu ' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']))->setHTMLBody("<b>Tento e-mail byl odeslan z webu " . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']) . "</b><br /><br />" . "<b>Odesílatel: </b>" . (isset($form_values['email']) ? $form_values['email'] : "nezadáno") . "<br />" . "<b>Telefon: </b>" . (isset($form_values['phone_number']) ? $form_values['phone_number'] : "nezadán") . "<br />" . "<b>Text zprávy: </b><br />" . (isset($form_values['text']) ? $form_values['text'] : "nezadán") . "<br />"); $mailer->send($mail); $this->flashMessage($this->formData->message_ok); } $this->redirect('Default:page', array('id' => $parameters['parent_page_id'], "seo_url_text" => $this->pages[$parameters['parent_page_id']]["final_url_text"])); }
public function sendPasswordFormSucceeded($form) { $values = $form->getValues(); $user = $this->database->table('users')->where('email', $values['email'])->fetch(); $mail = new Message(); $mail->setFrom('*****@*****.**')->addTo($values['email'])->setSubject('Zapomenuté heslo')->setBody("Dobrý den, \n Heslo si můžete změnit zde: \n" . "http://localhost/MyWallet/www/user/password?code=" . sha1($user->username) . ". Přejeme mnoho bezstarostných výdajů.\n\n Váš MyWallet tým."); $mailer = new SendmailMailer(); $mailer->send($mail); }
/** * Funkce pro odeslání potvrzovacího e-mailu po registraci uživatele * @param User $user */ public function sendRegistrationMail(User $user) { $mail = new Message(); $mail->setFrom('*****@*****.**'); //TODO tady by měla bát nějaká rozumná adresa $mail->addTo($user->email); $mail->setSubject('Registrace na webu...'); $mail->setHtmlBody('<p>Byli jste úspěšně zaregistrováni, pro přihlášení využijte e-mail <strong>' . $user->email . '</strong></p>'); $mailer = new SendmailMailer(); $mailer->send($mail); }
/* require framework */ require 'php/Nette/nette.phar'; /* configure neccessary */ $configurator = new Nette\Configurator(); $configurator->setTempDirectory(__DIR__ . '/php/temp'); $container = $configurator->createContainer(); /* get post */ $httpRequest = $container->getService('httpRequest'); $httpResponse = $container->getService('httpResponse'); $post = $httpRequest->getPost(); if ($httpRequest->isAjax()) { /* compose htmlContent */ $htmlContent .= '<table>'; foreach ($post as $key => $value) { if (isset($fields[$key])) { $htmlContent .= "<tr><th>{$fields[$key]}</th><td>{$value}</td></tr>"; } } $htmlContent .= '</table>'; /* compose html body */ $htmlBody = $htmlHeader . $htmlContent . $htmlFooter; /* send email */ $mail = new Message(); $mail->setFrom($from)->addTo($sendTo)->setSubject($subject)->setHtmlBody($htmlBody, FALSE); $mailer = new SendmailMailer(); $mailer->send($mail); $responseArray = array('type' => 'success', 'message' => $okMessage); $httpResponse->setCode(200); $response = new \Nette\Application\Responses\JsonResponse($responseArray); $response->send($httpRequest, $httpResponse); }
private function sendTicket($ticket) { $event = $ticket->event; $message = "<p>Děkujeme o Váš zájem, zde je Vaše vstupenka, můžete si ji vytisknout nebo připravit do mobilního telefonu.</p>\n" . "<img src=\"http://hudebnisos.cz/content/ticket/" . $event->id . ".jpg\" width=\"600\" />\n" . "<p>Vaše vstupenka má originální číslo <b>" . $ticket->id . "</b>.</p><br/><br/>\n" . "<p><a href=\"http://hudebnisos.cz/event/show/" . $event->id . "\">odkaz na akci " . $event->name . "</p>\n" . "<p><a href=\"http://hudebnisos.cz/\">www.hudebnisos.cz</a></p>\n"; $mail = new Nette\Mail\Message(); $mail->setSubject('SOS Vstupenka - ' . $event->name); $mail->setHtmlBody($message); $mail->addTo($ticket->email); $mailer = new Nette\Mail\SendmailMailer(); $mailer->send($mail); }
/** Spracovanie formulara * @param \Nette\Application\UI\Form $form */ public function onZapisDotaz(Form $form) { $values = $form->getValues(); //Nacitanie hodnot formulara $templ = new Latte\Engine(); $params = array("nadpis" => sprintf('Správa z kontaktného formulará stránky %s', $this->nazov_stranky), "dotaz_meno" => sprintf('Užívateľ s menom %s poslal nasledujúcu správu:', $values->meno), "dotaz_text" => $values->text); $mail = new Message(); $mail->setFrom($values->meno . ' <' . $values->email . '>')->addTo($this->emails)->setSubject(sprintf('Správa z kontaktného formulará stránky %s', $this->nazov_stranky))->setHtmlBody($templ->renderToString(__DIR__ . '/Kontakt_email-html.latte', $params)); try { $sendmail = new SendmailMailer(); $sendmail->send($mail); $this->presenter->flashMessage($this->text_form['send_ok'], 'success'); } catch (Exception $e) { $this->presenter->flashMessage($this->text_form['send_er'] . $e->getMessage(), 'danger,n'); } $this->redirect('this'); }
public function forgotPasswordFormSubmitted($button) { //Inicializacia $values = $button->getForm()->getValues(); //Nacitanie hodnot formulara $clen = $this->users->findOneBy(['email' => $values->email]); $new_password_requested = StrFTime("%Y-%m-%d %H:%M:%S", Time()); $new_password_key = $this->hasser->HashPassword($values->email . $new_password_requested); if (isset($clen->email) && $clen->email == $values->email) { //Taky clen existuje $templ = new Latte\Engine(); $params = ["site_name" => $this->nazov_stranky, "nadpis" => sprintf($this->trLang('email_reset_nadpis'), $this->nazov_stranky), "email_reset_txt" => $this->trLang('email_reset_txt'), "email_nefunkcny_odkaz" => $this->trLang('email_nefunkcny_odkaz'), "email_pozdrav" => $this->trLang('email_pozdrav'), "nazov" => $this->trLang('forgot_pass'), "odkaz" => 'http://' . $this->nazov_stranky . $this->link("User:resetPassword", $clen->id, $new_password_key)]; $mail = new Message(); $mail->setFrom($this->nazov_stranky . ' <' . $this->clen->users->email . '>')->addTo($values->email)->setSubject($this->trLang('forgot_pass'))->setHtmlBody($templ->renderToString(__DIR__ . '/templates/User/forgot_password-html.latte', $params)); try { $sendmail = new SendmailMailer(); $sendmail->send($mail); $this->users->find($clen->id)->update(['new_password_key' => $new_password_key, 'new_password_requested' => $new_password_requested]); $this->flashMessage($this->trLang('forgot_pass_email_ok'), 'success'); } catch (Exception $e) { $this->flashMessage($this->trLang('send_email_err') . $e->getMessage(), 'danger,n'); } $this->redirect('Homepage:'); } else { //Taky clen neexzistuje $this->flashMessage(sprintf($this->trLang('forgot_pass_user_err'), $values->email), 'danger'); } }
public function processAddWebForm(Form $form) { if ($form->isSubmitted()) { $values = $form->getValues(); $values['added'] = new \DateTime(); unset($values['spam']); unset($values['form_created']); // vlozime do DB $this->publicNominations->create($values); if (\Nette\Diagnostics\Debugger::$productionMode) { $cc = $values['cc'] == 1 ? "ano" : "ne"; $representative = $values['representative'] == 1 ? "ano" : "ne"; if ($this->sendEmails) { $mail = new Message(); $mail->setFrom('Webarchiv.cz <' . SYSTEM_EMAIL . '>')->addTo(SYSTEM_EMAIL)->setSubject('Nová nominace webu')->setBody("URL: " . $values['url'] . "\n\nJednatel: " . $representative . "\n\nCC: " . $cc . "\n\nJméno: " . $values['name'] . "\n\nE-mail: " . $values['email'] . "\n\nPoznámka: " . $values['note']); $mailer = new SendmailMailer(); $mailer->send($mail); } } if ($this->lang == 'cs') { $this->flashMessage('Děkujeme za vložení nového webu! Naši kurátoři se Vám brzy ozvou.', 'success'); } else { $this->flashMessage('Thank you for your nomination! Our curators will contact you soon.', 'success'); } } $this->redirect('this'); }
/** * Send email with token. * @param $token * @param $email * @param $presenter_type * @return bool */ public function sendEmail($token, $email, $presenter_type) { // TODO language templates, select automatically as Adminer try { $mail = new Nette\Mail\Message(); $mail->setFrom(self::VERIFY_MAIL_FROM)->addTo($email)->setSubject($_SERVER['SERVER_NAME'] . ' requires email verification.')->setBody('Dear Madam or Sir,' . "\n\n" . 'someone (presumably you) has requested your password to be set or reset for your ' . $_SERVER['SERVER_NAME'] . ' account.' . "\n\n" . $email . "\n\n" . 'Please use the following link for email verification:' . "\n" . 'http://' . $_SERVER['SERVER_NAME'] . '/' . 'skeleton/web/' . $presenter_type . '/?token=' . $token . "\n\n" . 'If you didn\'t request your password to be reset, please ignore this email, and no change will be made.' . "\n\n" . 'With kind regards,' . "\n" . $_SERVER['SERVER_NAME'] . "\n"); $mailer = new Nette\Mail\SendmailMailer(); $mailer->send($mail); return true; } catch (Nette\InvalidStateException $e) { \Tracy\Debugger::log('A problem with sending email. (' . $email . ').: ' . $e->getMessage()); return false; } }
public function userMailChangeFormSubmitted($button) { $values = $button->getForm()->getValues(); //Nacitanie hodnot formulara $this->clen = $this->user_profiles->find($values->id); //Najdenie clena if (!$this->hasser->CheckPassword($values->heslo, $this->clen->users->password)) { $this->flashRedirect('this', $this->trLang('pass_incorect'), 'danger'); } // Over, ci dany email uz existuje. Ak ano konaj. if ($this->users->testEmail($values->email)) { $this->flashMessage(sprintf($this->trLang('mail_change_email_duble'), $values->email), 'danger'); return; } //Vygeneruj kluc pre zmenu e-mailu $email_key = $this->hasser->HashPassword($values->email . StrFTime("%Y-%m-%d %H:%M:%S", Time())); $clen = $this->user_profiles->find(1); //Najdenie odosielatela emailu $templ = new Latte\Engine(); $params = ["site_name" => $this->nazov_stranky, "nadpis" => sprintf($this->trLang('email_change_mail_nadpis'), $this->nazov_stranky), "email_change_mail_txt" => sprintf($this->trLang('email_change_mail_txt'), $this->nazov_stranky), "email_change_mail_txt1" => $this->trLang('email_change_mail_txt1'), "email_nefunkcny_odkaz" => $this->trLang('email_nefunkcny_odkaz'), "email_pozdrav" => $this->trLang('email_pozdrav'), "nazov" => $this->trLang('mail_change'), "odkaz" => 'http://' . $this->nazov_stranky . $this->link("UserLog:activateNewEmail", $this->clen->id, $email_key)]; $mail = new Message(); $mail->setFrom($this->nazov_stranky . ' <' . $clen->users->email . '>')->addTo($values->email)->setSubject($this->trLang('mail_change'))->setHtmlBody($templ->renderToString(__DIR__ . '/templates/UserLog/email_change-html.latte', $params)); try { $sendmail = new SendmailMailer(); $sendmail->send($mail); $this->users->find($this->clen->id_users)->update(['new_email' => $values->email, 'new_email_key' => $email_key]); $this->flashRedirect('UserLog:', $this->trLang('mail_change_send_ok'), 'success'); } catch (Exception $e) { $this->flashMessage($this->trLang('mail_change_send_err') . $e->getMessage(), 'danger'); } }
public function newsletterFormSucceeded(UI\Form $form, $values) { if (!$values['event_id']) { $values['event_id'] = null; } $this->saveFormValues($values); $contacts = array(); if (!$values['event_id'] && $values['notTest']) { foreach ($this->registration as $registration) { $contacts[] = $registration->email; } foreach ($this->ticket as $ticket) { $contacts[] = $ticket->email; } $contacts = array_unique($contacts); } elseif ($values['notTest']) { foreach ($this->registration->where('event_id = ?', $values['event_id']) as $registration) { $contacts[] = $registration->email; } foreach ($this->ticket->where('event_id = ?', $values['event_id']) as $ticket) { $contacts[] = $ticket->email; } $contacts = array_unique($contacts); } else { $contacts = [0 => self::EMAIL_OPERATOR]; } $mail = new Nette\Mail\Message(); $mail->setFrom('Hudební S.O.S. <*****@*****.**>')->setSubject($values['subject'])->setHtmlBody(' <html><head><title>' . $values['subject'] . '</title></head> <body> <div style="background-color: rgb(197, 230, 235);color: rgb(0, 117, 117);letter-spacing: 0.3px; margin: auto auto; padding:1em 1em"> ' . $values['text'] . ' <br /><br /> </div> <hr style="border:0;border-top: 1px solid #DDD;" /> <center> <small> <font style="color:silver;font-family:\'Helvetica Neue\', sans-sherif">Pro odhlášení odpovězte na tento email slovy "Prosím odhlásit".</font> </small> </center> </body></html>'); /** @var Nette\Http\FileUpload $attach */ foreach ($values['files'] as $attach) { $mail->addAttachment($attach->getSanitizedName(), $attach->getContents()); } $counter = 0; foreach ($contacts as $contact) { $counter++; $mail->addBcc($contact); } $mailer = new Nette\Mail\SendmailMailer(); try { $mailer->send($mail); if (!$values['notTest']) { $this->flashMessage("Byl odeslán testovací email.", 'success'); } else { $this->flashMessage("Bylo odesláno {$counter} emailů.", 'success'); } } catch (\Exception $e) { $this->flashMessage('Při odesílání došlo k chybě. :: ' . $e->getMessage()); } $this->redirect('this'); }
public function actionResetPassword($id) { try { $data = $this->database->table('users')->get($id); $password_base = $id . $data->username; $update['password'] = password_hash($password_base, PASSWORD_DEFAULT); $update['token'] = rand(1000000, 999999999); $data->update($update); $this->flashMessage('Heslo bylo resetováno.', 'info'); $template = $this->createTemplate()->setFile(dirname(__FILE__) . '/templates/emails/_password_email.latte'); $template->id = $id . '-' . $update['token']; $template->username = $data->username; $mail = new Message(); $mail->setFrom('*****@*****.**')->addTo($data->email)->setSubject('Bazenycz - reset hesla')->setHtmlBody($template); $mailer = new SendmailMailer(); $mailer->send($mail); $this->flashMessage('Email s odkazem na změnu hesla byl odeslán.', 'info'); $this->redirect('User:default'); } catch (Exception $exc) { echo $exc->getTraceAsString(); } }
public function send() { $mailer = new SendmailMailer(); $mailer->send($this); }
/** * Handle message delivery. * * @return bool */ public static function sendMail() { // Allow support for legacy argument style or new style. $args = func_get_args(); if (func_num_args() == 1) { $options = $args[0]; } else { $options = array_merge(array('to' => $args[0], 'subject' => $args[1], 'message' => $args[2], 'reply_to' => $args[3], 'delivery_date' => $args[4]), $args[5]); } $di = \Phalcon\Di::getDefault(); $config = $di->get('config'); $mail_config = $config->application->mail->toArray(); // Do not deliver mail on development environments. if (DF_APPLICATION_ENV == "development" && !defined('DF_FORCE_EMAIL')) { $email_to = $mail_config['from_addr']; if (!empty($email_to)) { $options['to'] = $email_to; } else { return false; } } if (isset($mail_config['use_smtp']) && $mail_config['use_smtp']) { $smtp_config = $config->apis->smtp->toArray(); $smtp_config['host'] = $smtp_config['server']; unset($smtp_config['server']); $transport = new SmtpMailer($smtp_config); } else { $transport = new SendmailMailer(); } if (!is_array($options['to'])) { $options['to'] = array($options['to']); } else { $options['to'] = array_unique($options['to']); } foreach ((array) $options['to'] as $mail_to_addr) { if (empty($mail_to_addr)) { continue; } $mail_to_addr = str_replace('mailto:', '', $mail_to_addr); $mail = new Message(); $mail->setSubject($options['subject']); $from_addr = isset($options['from']) ? $options['from'] : $mail_config['from_addr']; $from_name = isset($options['from_name']) ? $options['from_name'] : $mail_config['from_name']; $mail->setFrom($from_addr, $from_name); if (isset($mail_config['bounce_addr'])) { $mail->setReturnPath($mail_config['bounce_addr']); } /* // Include a specific "Direct replies to" header if specified. if ($options['reply_to'] && $validator->isValid($options['reply_to'])) $mail->setReplyTo($options['reply_to']); else if (isset($mail_config['reply_to']) && $mail_config['reply_to']) $mail->setReplyTo($mail_config['reply_to']); */ // Change the type of the e-mail's body if specified in the options. if (isset($options['text_only']) && $options['text_only']) { $mail->setBody(strip_tags($options['message'])); } else { $mail->setHtmlBody($options['message'], false); } // Add attachment if specified in options. if (isset($options['attachments'])) { foreach ((array) $options['attachments'] as $attachment) { $mail->addAttachment($attachment); } } /* // Modify the mail type if specified. if (isset($options['type'])) $mail->setType($options['type']); */ // Catch invalid e-mails. try { $mail->addTo($mail_to_addr); } catch (\Nette\Utils\AssertionException $e) { continue; } $transport->send($mail); } return true; }