Ejemplo n.º 1
0
 function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $email = $form->getValues()->email;
     if ($form->values->layer == 'admin') {
         $lostPass = $this->database->table("helpdesk_emails")->where("template", "lostpass-admin")->fetch();
     } else {
         $lostPass = $this->database->table("helpdesk_emails")->where("template", "lostpass-member")->fetch();
     }
     if (!\Nette\Utils\Validators::isEmail($email)) {
         $this->presenter->flashMessage("Adresa je neplatná");
         $this->presenter->redirect(":Front:Sign:lostpass");
     }
     $passwordGenerate = \Nette\Utils\Random::generate(12, "987654321zyxwvutsrqponmlkjihgfedcba");
     if ($this->database->table('users')->where(array('email' => $email))->count() == 0) {
         $this->flashMessage("E-mail nenalezen");
         $this->presenter->redirect(":Front:Sign:lostpass");
     }
     $member = new \App\Model\MemberModel($this->database);
     $member->setActivation($email, $passwordGenerate);
     $latte = new \Latte\Engine();
     $latte->setLoader(new \Latte\Loaders\StringLoader());
     $params = array('code' => $passwordGenerate, 'email' => $email, 'settings' => $this->presenter->template->settings);
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($email)->setSubject("Informace o novém hesle")->setHTMLBody($latte->renderToString($lostPass->body, $params));
     $mailer = new \Nette\Mail\SendmailMailer();
     $mailer->send($mail);
     $this->presenter->flashMessage('Informace o zapomenutém hesle odeslány', 'success');
     $this->presenter->redirect(this);
 }
Ejemplo n.º 2
0
 function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $helpdesk = $this->database->table("helpdesk")->get(1);
     $helpdesk_admin = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(1);
     $helpdesk_customer = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(2);
     $arr = array("subject" => $form->values->name, "email" => $form->values->email, "message" => $form->values->message, "ipaddress" => getenv('REMOTE_ADDR'), "helpdesk_id" => 1, 'date_created' => date("Y-m-d H:i"), 'session_id' => session_id());
     if ($this->presenter->user->isLoggedIn()) {
         $arr["users_id"] = $this->presenter->template->member->id;
     }
     if ($helpdesk->fill_phone > 0) {
         $arr["phone"] = $form->values->phone;
     }
     $this->database->table("helpdesk_messages")->insert($arr);
     $params = array('name' => $form->values->name, 'email' => $form->values->email, 'phone' => $form->values->phone, 'message' => $form->values->message, 'ipaddress' => getenv('REMOTE_ADDR'), 'time' => date("Y-m-d H:i"), 'settings' => $this->presenter->template->settings);
     $latte = new \Latte\Engine();
     $latte->setLoader(new Latte\Loaders\StringLoader());
     //$latte->setTempDirectory(__DIR__ . '/../temp');
     $email_admin = $latte->renderToString($helpdesk_admin->body, $params);
     $email_customer = (string) $latte->renderToString($helpdesk_customer->body, $params);
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->presenter->template->settings["contacts:email:hq"]);
     $mail->addTo($this->presenter->template->settings["contacts:email:hq"]);
     $mail->setHTMLBody($email_customer);
     $mailA = new \Nette\Mail\Message();
     $mailA->setFrom($this->presenter->template->settings["contacts:email:hq"]);
     $mailA->addTo($form->values->email);
     $mailA->setHTMLBody($email_admin);
     $mailer = new \Nette\Mail\SendmailMailer();
     $mailer->send($mail);
     $mailer->send($mailA);
     $this->presenter->flashMessage($this->presenter->translator->translate('messages.sign.thanksForMessage'), "error");
     $this->presenter->redirect(":Front:Contact:default");
 }
Ejemplo n.º 3
0
 /**
  * @param $from
  * @param $to
  * @param $sujet
  * @param $message
  */
 public static function envoyerMail($from, $to, $sujet, $message)
 {
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($from)->addTo($to)->setSubject($sujet)->setHtmlBody($message);
     if (SMTP_HOST != "") {
         $mailer = new \Nette\Mail\SmtpMailer(['host' => SMTP_HOST, 'username' => SMTP_USER, 'password' => SMTP_PASS, 'secure' => SMTP_SECURE, 'port' => SMTP_PORT]);
     } else {
         $mailer = new \Nette\Mail\SmtpMailer();
     }
     $mailer->send($mail);
 }
Ejemplo n.º 4
0
 function sendFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $emailDb = $this->database->table("helpdesk_emails")->get($form->values->id);
     $latte = new \Latte\Engine();
     $params = array('body' => "Body");
     $paramsTemplate = array('name' => "John Doe", 'phone' => "+420 123 456 789", 'email' => $this->presenter->template->settings["contacts:email:hq"], 'address' => "42.42.42.256", 'time' => date("j. n. Y H:i:s"), 'message' => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " . "Aliquam purus lacus, tempor sit amet tincidunt ut, finibus non quam. " . "Quisque ac metus quis odio vestibulum consectetur congue id diam. " . "Sed ligula ante, suscipit sed purus ac, dignissim hendrerit nisi.<br /> " . "Praesent scelerisque nulla nec posuere accumsan. Etiam ac libero in " . "ipsum volutpat accumsan. Sed pretium sodales fermentum. Quisque sed feugiat odio. ");
     $latte->setLoader(new \Latte\Loaders\StringLoader());
     $renderedTemplate = $latte->renderToString($emailDb->body, $paramsTemplate);
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->presenter->template->settings["site:title"] . ' <' . $this->presenter->template->settings["contacts:email:hq"] . '>')->addTo($form->values->email)->setSubject($emailDb->subject)->setHTMLBody($renderedTemplate);
     $this->presenter->mailer->send($mail);
     $this->presenter->redirect(this, array("id" => $form->values->id));
 }
Ejemplo n.º 5
0
 public function send($to, $message, $args = [])
 {
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->config['from'], $this->config['display']);
     $mail->addTo($to);
     $dir = $this->config['templateDir'];
     $template = new \Nette\Templating\FileTemplate();
     $template->registerFilter(new \Nette\Latte\Engine());
     $template->registerHelperLoader('\\Nette\\Templating\\Helpers::loader');
     $template->setFile($dir . '/' . $message . '.latte');
     $template->setParameters($args);
     $template->recipient = $to;
     $mail->setHtmlBody($template);
     $this->mailer->send($mail);
 }
Ejemplo n.º 6
0
 function sendLoginFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $pwd = \Nette\Utils\Random::generate(10);
     $pwdEncrypted = \Nette\Security\Passwords::hash($pwd);
     $user = $this->database->table('users')->get($form->values->contact_id);
     $this->database->table("users")->get($user->id)->update(array("password" => $pwdEncrypted));
     if ($form->values->sendmail) {
         $latte = new \Latte\Engine();
         $latte->setLoader(new \Latte\Loaders\StringLoader());
         $params = array('username' => $user->username, 'email' => $user->email, 'password' => $pwd, 'settings' => $this->presenter->template->settings);
         $helpdesk = $this->database->table("helpdesk")->get(4);
         $helpdesk_resend_login = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(8);
         $helpdesk_resend = $latte->renderToString($helpdesk_resend_login->body, $params);
         $mail = new \Nette\Mail\Message();
         $mail->setFrom($this->presenter->template->settings["site:title"] . ' <' . $this->presenter->template->settings["contacts:email:hq"] . '>')->addTo($user->email)->setHTMLBody($helpdesk_resend);
         $mailer = new \Nette\Mail\SendmailMailer();
         $mailer->send($mail);
     } else {
         $this->presenter->flashMessage("pass", "success");
     }
     $this->presenter->redirect(this, array("id" => $form->values->contact_id, "pdd" => $pwd));
 }
 /**
  * @param UI\Form $form
  */
 public function recoveryFormSucceeded(UI\Form $form)
 {
     $values = $form->getValues();
     $user = $this->users->getBy(array('email' => $values->email));
     if (!empty($user)) {
         $token = $this->users->generateRecoveryToken($user->id);
         $template = $this->createTemplate();
         $template->setFile(__DIR__ . "/../templates/PasswordRecovery/emails/SendResetPassword.latte");
         $template->token = $token;
         $template->email = $user->email;
         // send email
         $mail = new \Nette\Mail\Message();
         $mail->setFrom($this->context->parameters['email']['from'])->addTo($user->email)->setHtmlBody($template);
         try {
             $this->mailer->send($mail);
             $this->template->emailSent = TRUE;
         } catch (\Exception $e) {
             $this->flashMessage('Unexpected error. Please try again later.', 'error');
         }
     } else {
         $this->flashMessage('E-mail not found.');
     }
 }
Ejemplo n.º 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $message = new \Nette\Mail\Message();
     if (!$this->validateEmail($from = trim($input->getOption('from')))) {
         $output->writeln('<error>Expected valid email address, given "' . $from . '"</error>');
         return 1;
     }
     $message->setFrom($from);
     if (!$this->validateEmail($to = trim($input->getArgument('recipient')))) {
         $output->writeln('<error>Expected valid email address, given "' . $to . '"</error>');
         return 1;
     }
     $message->addTo($to);
     $message->setSubject($input->getOption('subject'));
     $message->setBody($input->getOption('message'));
     if ($input->getOption('force') && $this->mailer instanceof \Simplement\MailQueue\Mailer) {
         $this->mailer->send($message, 1, FALSE);
     } else {
         $this->mailer->send($message);
     }
 }
Ejemplo n.º 9
0
 public function sendForgot(UI\Form $form)
 {
     $values = $form->getValues();
     $user = $this->context->createServiceUsers()->where('email', $values->email)->fetch();
     if ($user) {
         try {
             $template = $this->createTemplate();
             $template->setFile(__DIR__ . "/../templates/Sign/mail-forgot.latte");
             $template->setTranslator($this->translator);
             $template->hash = $user->hash ? $user->hash : sha1($user->username . $user->password);
             $user->update(array('hash' => $template->hash));
             //$mail = $this->mailingFactory->create();
             $msg = new \Nette\Mail\Message();
             $msg->setHtmlBody($template)->setFrom('*****@*****.**')->setSubject('Nové heslo na portálu Peknyden.cz')->addTo(trim($values->email));
             $this->mailer->send($msg);
             $this->flashMessage('Instrukce pro zjištění uživatelského jména a vytvoření nového hesla jsme zaslali na vámi uvedený e-mail.', 'success');
             //$this->redirect('Sign:ForgotDone');
         } catch (Exception $e) {
             $this->flashMessage('Neco se nezdarilo. Zkuste to prosim za chvili znovu', 'error');
         }
     } else {
         $form->addError('Neexistuje žádný uživatel s touto e-maiovou adresou. Zkuste to znovu.', 'error');
     }
 }
Ejemplo n.º 10
0
 public function saveGrab(MyForm $form)
 {
     $values = $form->getValues();
     $template = $this->createTemplate();
     $template->setFile(__DIR__ . "/../templates/mail-place-request.latte");
     $template->values = $values;
     $template->user = $this->profile;
     $msg = new \Nette\Mail\Message();
     $msg->setHtmlBody($template)->setFrom($values->email)->setSubject('Nová žádost o přidělení místa na portálu Peknyden.cz')->addTo('*****@*****.**');
     $this->mailer->send($msg);
     $this->flashMessage('Děkujeme, žádost byla v pořádku odeslána. Během dvou pracovních dní ji vyřídíme a vyrozumíme vás o tom e-mailem.', 'success');
     $this->redirect('this');
 }
Ejemplo n.º 11
0
    download($img_url, __DIR__ . "/images/jianshu/");
}
$phindle = new Develpr\Phindle\Phindle(array("title" => "每日简书" . date('md'), "publisher" => "FalconPress", "creator" => "Falcon", "language" => Develpr\Phindle\OpfRenderer::LANGUAGE_ZH, "subject" => "简书", "description" => "a new book", "path" => __DIR__ . "/ebooks/", "isdn" => "000000000", "staticResourcePath" => __DIR__, "cover" => './images/cover.jpg', "kindlegenPath" => $config['KINDLEGEN_PATH'], "downloadimage" => true));
foreach ($article_arr as $i => $article) {
    if ($article['content'] == "") {
        continue;
    }
    $content = new Develpr\Phindle\Content();
    $content->setTitle($article['title']);
    $content->setHtml('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">' . "<h3>{$article['title']}</h3>" . $article['content']);
    $content->setPosition($i);
    $phindle->addContent($content);
}
$phindle->process();
$ebook_path = $phindle->getMobiPath();
$mail = new Nette\Mail\Message();
$mail->setFrom(sprintf('%s <%s>', $config['KD_SENDER']['from'], $config['KD_SENDER']['username']))->setSubject($phindle->getAttribute('title'))->addAttachment($ebook_path, null, 'application/octet-stream');
foreach ($config['KD_RECEIVER'] as $receiver) {
    $mail->addTo($receiver);
}
$mailer = new Nette\Mail\SmtpMailer($config['KD_SENDER']);
$result = $mailer->send($mail);
//获取图片本地存储路径
function get_image_filename($url, $local_prefix = "")
{
    $arr = parse_url($url);
    $basename = basename($arr['path']);
    if (strpos($basename, '.') === false) {
        return $local_prefix . $basename . '.jpg';
    } else {
        return $local_prefix . $basename;
Ejemplo n.º 12
0
 function send(\xepan\communication\Model_Communication_EmailSetting $email_setting, $mailer = null)
 {
     $this['status'] = 'Outbox';
     $this['direction'] = 'Out';
     $this['mailbox'] = $email_setting['email_username'] . '#SENT';
     $this['description'] = $this['description'] . $email_setting['signature'];
     if (!$this['to_id']) {
         $this->findContact('to');
     }
     $this['communication_channel_id'] = $email_setting->id;
     if (!$this->app->getConfig('test_mode', false)) {
         try {
             $mail = new \Nette\Mail\Message();
             $mail->setFrom($this['from_raw']['email'], $this['from_raw']['name'] ?: null);
             $return_path = $email_setting['return_path'];
             if (!$return_path) {
                 $return_path = $this['from_raw']['email'];
             }
             $mail->setReturnPath($return_path);
             foreach ($this['to_raw'] as $to) {
                 $mail->addTo(trim($to['email']), $to['name'] ?: null);
             }
             if ($this['cc_raw']) {
                 foreach ($this['cc_raw'] as $cc) {
                     $mail->addCC(trim($cc['email']), $cc['name'] ?: null);
                 }
             }
             if ($this['bcc_raw']) {
                 foreach ($this['bcc_raw'] as $bcc) {
                     $mail->addBcc(trim($bcc['email']), $bcc['name'] ?: null);
                 }
             }
             foreach ($this->getAttachments() as $attach) {
                 $mail->addAttachment($_SERVER["DOCUMENT_ROOT"] . $attach);
             }
             $mail->setSubject($this['title'])->setHTMLBody($this['description'], $this->app->pathfinder->base_location->base_path);
             if (!$mailer) {
                 if (isset($this->app->mailer)) {
                     $mailer = $this->app->mailer;
                 } else {
                     $mailer = new \Nette\Mail\SmtpMailer(array('host' => $email_setting['email_host'], 'username' => $email_setting['email_username'], 'password' => $email_setting['email_password'], 'secure' => $email_setting['encryption'], 'persistent' => true));
                     $this->app->mailer = $mailer;
                 }
             }
             $mailer->send($mail);
             $email_setting['last_emailed_at'] = $this->app->now;
             $email_setting['email_sent_in_this_minute'] = $email_setting['email_sent_in_this_minute'] + 1;
             $email_setting->save();
         } catch (\Exception $e) {
             $this->save();
             throw $e;
         }
     }
     if ($this->app->getConfig('test_mode', false)) {
         // echo "setting last_emailed_at on ". $email_setting['name']. ' as '. $this->app->now . '<br/>';
         $email_setting['last_emailed_at'] = $this->app->now;
         $email_setting['email_sent_in_this_minute'] = $email_setting['email_sent_in_this_minute'] + 1;
         $email_setting->save();
     }
     $this['status'] = 'Sent';
     $this->save();
 }
 /**
  * @return Nette\Mail\Message
  */
 public function createServiceNette__mail()
 {
     $service = new Nette\Mail\Message();
     trigger_error('Service nette.mail is deprecated.', 16384);
     $service->setMailer($this->getService('nette.mailer'));
     return $service;
 }
Ejemplo n.º 14
0
require 'asystem.pps-eu.cz/vendor/autoload.php';
require 'CRON.2hodiny/functions.php';
$dsn = 'mysql:host=127.0.0.1;dbname=pps-eucz01';
$user = '******';
$password = '******';
$connection = new Nette\Database\Connection($dsn, $user, $password);
$database = new Nette\Database\Context($connection);
$results = $database->table('nemovitost')->where('mod', 1)->where('TIMESTAMPDIFF(MINUTE, datum_konec, NOW()) BETWEEN 0 AND 120');
if ($results) {
    // pokud mam nejake nemovitosti u kterych aukce skoncila v poslednich dvou hodinach
    foreach ($results as $r) {
        // postupne tyto nemovitosti projedu
        $prihozy = $database->table('drazba')->where('id_nemovitost', $r->id);
        $drazba = analyzuj_drazbu($prihozy, $r);
        if ($drazba) {
            $kupce = $database->table('uzivatel')->get($drazba['id']);
            if ($kupce->email != null) {
                // nastaveni parametru pro latte emailu
                $latte = new Nette\Latte\Engine();
                $params = array('nemovitost' => $r, 'kupce' => $kupce, 'cena' => $drazba['cena']);
                // nastaveni mailu
                $mail = new Nette\Mail\Message();
                $mail->setFrom('*****@*****.**')->addTo($kupce->email)->setHtmlBody($latte->renderToString('CRON.2hodiny/email.latte', $params));
                // poslani mailu
                $mailer = new Nette\Mail\SmtpMailer(array('host' => 'smtp.seznam.cz', 'username' => '*****@*****.**', 'password' => 'pps2015', 'secure' => 'ssl'));
                $mailer->send($mail);
            }
        }
    }
}
Ejemplo n.º 15
0
 function signUpFormSucceeded(\Nette\Forms\BootstrapUIForm $form)
 {
     $activationCode = \Nette\Utils\Random::generate(12, "987654321zyxwvutsrqponmlkjihgfedcba");
     $password = \Nette\Security\Passwords::hash($form->values->pwd);
     $arr = array("email" => $form->values->email, "username" => $form->values->username, "password" => $password, "activation" => $activationCode, "newsletter" => (bool) $form->values->newsletter, "state" => 0, "users_roles_id" => 4, "date_created" => date("Y-m-d H:i:s"));
     if ($this->presenter->template->settings['members:groups:enabled']) {
         $arr["categories_id"] = $form->values->group;
     }
     $userId = $this->database->table("users")->insert($arr);
     $this->database->table("users")->where(array("id" => $userId->id))->update(array("uid" => \Nette\Utils\Strings::padLeft($userId->id, 6, '0')));
     if ($this->template->settings['members:signup:contactEnabled']) {
         $arrContacts = array("categories_id" => 44, "users_id" => $userId, "name" => $form->values->name, "street" => $form->values->street, "city" => $form->values->city, "zip" => $form->values->zip, "countries_id" => 1);
         if ($this->presenter->template->settings['members:signup:companyEnabled']) {
             $arrContacts["company"] = $form->values->company;
             $arrContacts["vatin"] = $form->values->vatin;
             $arrContacts["vatid"] = $form->values->vatid;
         }
         $contactId = $this->database->table("contacts")->insert($arrContacts);
         $this->database->table("contacts")->get($contactId)->update(array("order" => $contactId));
     }
     if ($form->values->vatin) {
         $ares = new \h4kuna\Ares\Ares();
         $aresArr = $ares->loadData('')->toArray();
     }
     $latte = new \Latte\Engine();
     $latte->setLoader(new \Latte\Loaders\StringLoader());
     $params = array('username' => $form->values->username, 'activationCode' => $activationCode, 'settings' => $this->presenter->template->settings, 'form' => $form, 'aresArr' => $aresArr);
     $helpdesk = $this->database->table("helpdesk")->get(3);
     $helpdesk_signup_member = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(5);
     $helpdesk_signup_confirmbyadmin = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(6);
     $helpdesk_signup_adminconfirm = $helpdesk->related("helpdesk_emails", "helpdesk_id")->get(7);
     try {
         if ($this->presenter->template->settings['members:signup:confirmByAdmin']) {
             $email_signup_confirmbyamin = $latte->renderToString($helpdesk_signup_confirmbyadmin->body, $params);
             $email_signup_adminconfirm = $latte->renderToString($helpdesk_signup_adminconfirm->body, $params);
             $mail = new \Nette\Mail\Message();
             $mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($form->values->email)->setHTMLBody($email_signup_confirmbyamin);
             $this->presenter->mailer->send($mail);
             $mailA = new \Nette\Mail\Message();
             $mailA->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($this->presenter->template->settings['contacts:email:hq'])->setHTMLBody($email_signup_adminconfirm);
             $this->presenter->mailer->send($mailA);
             $this->flashMessage('Registrace byla dokončena. Po ověření Vám bude zaslán e-mail, po kterém se můžete přihlásit', 'note');
         } else {
             $email_signup_member = $latte->renderToString($helpdesk_signup_member->body, $params);
             $mail = new \Nette\Mail\Message();
             $mail->setFrom($this->presenter->template->settings['contacts:email:hq'])->addTo($form->values->email)->setHTMLBody($email_signup_member);
             $this->presenter->mailer->send($mail);
             $this->presenter->flashMessage('Vaše registrace proběhla úspěšně. Po ověření se můžete přihlásit.', 'note');
         }
         $this->presenter->redirect(":Front:Sign:ed");
     } catch (\Nette\Mail\SmtpException $e) {
         $this->presenter->flashMessage('E-mail nebyl odeslán' . $e->getMessage(), 'error');
         $this->presenter->redirect(":Front:Sign:up");
     }
 }
Ejemplo n.º 16
0
 /**
  * Prepare the Message object and return it
  * @return \Nette\Mail\Message
  */
 protected function prepareMessage()
 {
     if (empty($this->subject) && empty($this->textBody) && empty($this->htmlBody)) {
         throw new \LogicException('Subject and body cannot be empty');
     }
     if (empty($this->to) && empty($this->cc) && empty($this->bcc)) {
         throw new \LogicException('No recipients were specified for this email');
     }
     $message = new \Nette\Mail\Message();
     $message->setSubject($this->subject);
     if (!empty($this->htmlBody)) {
         $message->setHtmlBody($this->htmlBody);
     }
     if (!empty($this->textBody)) {
         $message->setBody($this->textBody);
     }
     return $message;
 }
 /**
  *  send gmail
  *
  *  TODO: 請加入附件, 但應該不是在這個 method 擴充
  *
  *  @return boolean
  */
 public static function sendMessage($from, $to, $subject, $body)
 {
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($from)->addTo($to)->setSubject($subject)->setBody($body);
     $messageText = $mail->generateMessage();
     $data = self::_encodeRawData($messageText);
     try {
         $message = new Google_Service_Gmail_Message();
         $message->setRaw($data);
         self::getService()->users_messages->send("me", $message);
     } catch (Exception $e) {
         echo 'Send message error ' . $e->getMessage() . "\n";
         return false;
     }
     return true;
 }
Ejemplo n.º 18
0
 /**
  * @param Form $form
  */
 public function recoveryFormSucceeded(Form $form)
 {
     if ($this->recoveryCounter > 3) {
         sleep(3);
     }
     $values = $form->getValues();
     $user = $this->users->getByEmail($values->email);
     if (!empty($user)) {
         $token = $this->users->generateRecoveryToken($user->id);
         $template = $this->createTemplate();
         $template->administrationTemplates = $this->administrationTemplatesDir;
         $template->setFile(__DIR__ . "/templates/PasswordRecovery.sendResetPassword.latte");
         $template->token = $token;
         $template->email = $user->email;
         // send email
         $mail = new \Nette\Mail\Message();
         $mail->setFrom($this->context->parameters['email']['from'])->addTo($user->email)->setHtmlBody($template, __DIR__ . '/templates');
         try {
             $this->mailer->send($mail);
         } catch (\Exception $e) {
             $this->flashMessage('Unexpected error. Please try again later.', 'error');
         }
         $this->redirect('sended');
     } else {
         $form->addError('Entered E-mail not found. Try another one.');
         //			$this->flashMessage('E-mail not found.', 'error');
     }
 }
Ejemplo n.º 19
0
 public function sendEmail()
 {
     $model = $this->createGridModel();
     $items = $model->getItems();
     $values = $this['email']->values;
     foreach ($items as $riesitel) {
         try {
             $mail = new \Nette\Mail\Message();
             $mail->setFrom('*****@*****.**');
             $mail->addTo($riesitel['email']);
             $mail->setSubject($values['subject']);
             $mail->setBody($values['body']);
             $mail->send();
         } catch (\Exception $e) {
             $this['grid']->flashMessage($e->getMessage());
         }
     }
     $this->redirect('this');
 }
Ejemplo n.º 20
0
 /**
  * @param null|string $message
  * @return \Nette\Mail\Message
  */
 protected function getCopyMail($message = NULL)
 {
     $values = $this['form']['_inputs']->getValues();
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($this->mailformEntity->emails[0], $this->mailformEntity->recipient);
     $mail->addTo($values['_email'], $values['_name']);
     $mail->setSubject($this->mailformEntity->subject);
     $mail->setBody($message ? $message : $this->getCopyMessage());
     return $mail;
 }
Ejemplo n.º 21
0
 /** Send mail.
  * 
  * @param string $from - who will be set as sender?
  * @param string $to - who should receive it
  * @param string $subject
  * @param string $templateName - templates/Email/$templateName.latte
  * @param mixed $params - is passed to template as it is, can be everything
  */
 public function sendMail($from, $to, $subject, $templateName, $params)
 {
     $template = $this->createTemplate();
     $template->setFile(__DIR__ . '/../templates/Email/' . $templateName . '.latte');
     $template->registerFilter(new Nette\Latte\Engine());
     $template->params = $params;
     $template->subject = $subject;
     $template->pageUrl = $this->pageUrl;
     $mail = new Nette\Mail\Message();
     $mailer = new Nette\Mail\SmtpMailer(array('host' => $this->context->parameters['email']['smtp'], 'username' => $this->context->parameters['email']['username'], 'password' => $this->context->parameters['email']['password'], 'secure' => $this->context->parameters['email']['secure']));
     $mail->setFrom($from)->addTo($to)->setHtmlBody($template);
     //$mail->setMailer($mailer);
     $mail->send();
 }
 /**
  * @return Nette\Mail\Message
  */
 public function createNette__mail()
 {
     $service = new Nette\Mail\Message();
     $service->setMailer($this->getService('nette.mailer'));
     return $service;
 }
Ejemplo n.º 23
0
 /**
  * process to reset form
  * @param \Nette\Application\UI\Form $form
  * @return void
  */
 public function processResetForm(\Nette\Application\UI\Form $form)
 {
     $values = $form->getValues();
     $this->user->setAuthenticator(new \UserModule\Authenticator($this->db));
     try {
         $data = $this->user->getAuthenticator()->resetPassword($values->username, $values->email);
         $message = new \Nette\Mail\Message();
         $message->setFrom('system@occ2')->addTo($data["email"])->setSubject(_("Reset password"))->setBody(_("Hello your new reseted password is ") . $data["password"]);
         $mail = new \Nette\Mail\SendmailMailer();
         $mail->send($message);
         $this->flashMessage(_("Your new password was send to your email", "success"));
         $this->redirect("login");
     } catch (\Nette\Security\AuthenticationException $exc) {
         $this->flashMessage($exc->getMessage(), "danger");
         $this->redirect("this");
     }
 }