/** * Sends new mail * @param type $mail */ private function send($mail) { // $mailer = new SendmailMailer; // $mailer->send($mail); $mailer = new Nette\Mail\SmtpMailer(array('host' => 'smtp.seznam.cz', 'username' => '*****@*****.**', 'password' => 'heslojeveslo9', 'secure' => 'ssl')); $mailer->send($mail); }
function dosend() { if (!tr::config()->get("app.mail.enable")) { return true; } $className = get_called_class(); $mailConfig = tr::config()->get("app.mail.smtp"); $mailer = new SmtpMailer($mailConfig); return $mailer->send(self::$_instance[$className]); }
/** * @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"); }
public function __destruct() { $view = $this->view; if ($view instanceof View) { extract($view->data); require $view->view; } $mail = $this->mail; if ($mail instanceof Mail) { $mailer = new Smtp($mail->config); $mailer->send($mail); } }
public function sendEmail($email = null, $latte_name, $product, $winners_bid, $cost, $title) { if ($email != null || $email != "") { // nastaveni parametru pro latte emailu $latte = new Latte\Engine(); $params = array('product' => $product, 'winners_bid' => $winners_bid, 'cost' => $cost, 'title' => $title); // nastaveni mailu $mail = new Nette\Mail\Message(); $mail->setFrom($this->mailer['username'])->addTo($email)->setHtmlBody($latte->renderToString(__DIR__ . '/../presenters/templates/Email/' . $latte_name . '.latte', $params)); // poslani mailu $mailer = new Nette\Mail\SmtpMailer($this->mailer); $mailer->send($mail); } }
/** * Odešle vytvořenou zprávu přes SMTP. * @return bool * @throws \Nette\Mail\SmtpException V případě chyby. Pokud je prostředí produkční, je chyba zalogována do mailException. */ public function send() { try { $this->smtpMailer->send($this->message); return true; } catch (\Nette\Mail\SmtpException $e) { if (\Tracy\Debugger::$productionMode) { \Tracy\Debugger::log($e->getMessage(), "mailException"); return false; } else { throw $e; } } }
/** * @param string $view email template * @param User $user * @param NULL|array $args template variables * * @throws Exception from Latte\Engine * @throws SmtpException from Mailer */ public function send($view, User $user, array $args = []) { if ($this->orm->unsubscribes->getByEmail($user->email)) { // Last line of defense. Make sure unsubscribed users // really dont receive any email. This should however // be handled before the task is queued. $this->logger->addAlert("Email to '{$user->email}' not send, user unsubscribed. Find out why it was queued"); return; } $msg = new Message(); $msg->setFrom('Khanova škola <*****@*****.**>'); $msg->addReplyTo('Markéta Matějíčková <*****@*****.**>'); $msg->addTo($user->email, $user->name); $token = Unsubscribe::createFromUser($user); $token->emailType = $view; $this->orm->tokens->attach($token); $this->orm->flush(); $args['recipient'] = $user; $args['email'] = $msg; $args['unsubscribe'] = (object) ['token' => $token, 'code' => $token->getUnsafe()]; $args['baseUrl'] = rtrim($this->baseUrl, '/'); $latte = new Engine(); /** @var Presenters\Token $presenter */ $presenter = $this->factory->createPresenter('Token'); $presenter->autoCanonicalize = FALSE; $ref = new \ReflectionProperty(Presenter::class, 'globalParams'); $ref->setAccessible(TRUE); $ref->setValue($presenter, []); $latte->addFilter('token', function (Token $token, $unsafe) use($presenter, $view) { return $presenter->link('//Token:', ['token' => $token->toString($unsafe), 'utm_campaign' => "email-{$view}"]); }); $latte->addFilter('vocative', function ($phrase) { return $this->inflection->inflect($phrase, 5); }); $template = $latte->renderToString($this->getTemplate($view), $args); $msg->setHtmlBody($template); $this->mailer->send($msg); $this->logger->addInfo('Email send', ['view' => $view, 'email' => $user->email]); }
private function send(Message $n) { $mailerType = $this->getDesiredMailerType(); $mailer = null; if ($mailerType == self::MAILER_TYPE_SEND) { $mailer = new SendmailMailer(); } else { $mailer = new SmtpMailer($this->getSmtpOptions()); } try { $mailer->send($n); } catch (Exceptions\InvalidStateException $ex) { $this->logger->addError($ex); } }
function run($data, $page) { # Create the email $view = new ConfirmationEmail($this, $data['_timestamp']); $stringifier = new Stringifier(); $html = '<!DOCTYPE html>' . $stringifier->stringify($view); # ... and send it! $mail = new Message(); $mail->setFrom($this->from)->addTo($data[$this->emailField])->setSubject($this->subject)->setHTMLBody($html); $mailer = new SmtpMailer(Config::get()['smtp']); $mailer->send($mail); return $data; }
/** * Checks if is not in production mode * If is in production sends email, else does not * @param Message * @return void */ public function send(\Nette\Mail\Message $mail) { if ($this->productionMode || $this->sendEmailInDevelopment) { parent::send($mail); } }
private function sendDeleteMail($email) { $latte = new \Latte\Engine(); $mail = new Message(); $mail->setFrom('*****@*****.**', 'Ololoď')->addTo($email)->addReplyTo('*****@*****.**', 'Ololoď')->setSubject('Ololoď – rezervace zrušena')->setHtmlBody($latte->renderToString(__DIR__ . '/../presenters/templates/Emails/deleted.latte')); $mailer = new SmtpMailer(array('host' => 'mail.gigaserver.cz', 'username' => '*****@*****.**', 'password' => 'wu6raCet', 'secure' => 'ssl')); $mailer->send($mail); }
public function prihozFormSucceeded($button) { $id = (int) $this->getParameter('id'); $values = $button->getForm()->getValues(true); $values['datum_vkladu'] = date('Y-m-d H:i:s'); if ($values['pocet'] == $this->database->findAll('drazba')->where('id_nemovitost', $values['id_nemovitost'])->count('*')) { // pokud se shoduji pocty prihozu pri nacteni a tesne pred prihozenim, pak vse ok unset($values['pocet']); // priprava promennych pro poslani emailu o prehozeni $nemovitost = $this->database->findById('nemovitost', $id); $prihozy = $this->database->findAll('drazba')->where('id_nemovitost', $id); $drazba = $this->drazba->vyhodnotDrazbu($id, $prihozy); if ($drazba["email"] != null || $drazba["email"] != "") { // nastaveni parametru pro latte emailu $latte = new Nette\Latte\Engine(); $params = array('nemovitost' => $nemovitost, 'uzivatel' => $drazba["jmeno"], 'cena' => $drazba["cena"] + $values["vkladana_castka"]); // nastaveni mailu $mail = new Nette\Mail\Message(); $mail->setFrom('*****@*****.**')->addTo($drazba["email"])->setHtmlBody($latte->renderToString(__DIR__ . '/../templates/Aukce/email.latte', $params)); // poslani mailu $mailer = new Nette\Mail\SmtpMailer(array('host' => 'smtp.seznam.cz', 'username' => '*****@*****.**', 'password' => 'pps2015', 'secure' => 'ssl')); $mailer->send($mail); } // prihozeni $this->database->insert('drazba', $values); $this->flashMessage('Přihodil(a) jste ' . number_format($values['vkladana_castka']) . ' Kč.'); $this->redirect('Nemovitosti:detailNemovitosti', $values['id_nemovitost']); } else { $this->flashMessage('Znovu zvažte přihození, někdo před Vámi ještě navýšil cenu.'); $this->redirect('Aukce:prihodit', $values['id_nemovitost']); } }
public function actionResults() { if ($this->sessionSection->id_respondent === null) { $this->redirect("Survey:personal"); } 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/Survey/email.latte', array("id" => $this->sessionSection->id_respondent))); $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); } }