Пример #1
0
 public function submitFormForgotPassword(Form $form)
 {
     $values = $form->getValues();
     $user = $this->user->where('email', $values['email'])->fetch();
     if (!$user) {
         $this->flashMessage($this->translator->translate('admin.sign.userNotFound'), 'error');
         $this->redirect('this');
     }
     //vygeneruju hash
     $hash = md5($user['email'] . rand());
     while ($this->user->where('hash', $hash)->fetch()) {
         $hash = md5($user->email . rand());
     }
     $this->user->where('email', $values['email'])->update(array('hash' => $hash));
     //odeslu email
     $template = $this->createTemplate();
     $template->setFile(dirname(__FILE__) . '/../templates/Sign/emailForgotPassword.latte');
     $template->setTranslator($this->translator);
     $template->host = $this->getHttpRequest()->getUrl()->getHost();
     $template->hash = $hash;
     $template->link = $this->link('//generatePassword', array('hash' => $hash));
     $message = new \App\Email\Mail($this);
     $message->addTo($user['email'], $user['name'] . ' ' . $user['surname']);
     $message->setSubject($this->translator->translate('admin.email.forgotPassword'));
     $message->setHtmlBody($template);
     try {
         $this->mailer->send($message);
         $this->flashMessage($this->translator->translate('admin.email.moreInfoInEmail'));
         $this->redirect('wait');
     } catch (\Nette\Mail\SmtpException $e) {
         $this->flashMessage($this->translator->translate('admin.email.notSend'), 'error');
     }
 }
Пример #2
0
 public function startup()
 {
     parent::startup();
     //test emailu
     if (isset($_GET['mailTest'])) {
         $message = new \App\Email\Mail($this);
         $message->setSubject('Testovací email');
         $message->setHtmlBody('<h1>Testovací email</h1><p>ěščřžýáíé</p>');
         try {
             $message->addTo('*****@*****.**');
             $message->addTo('*****@*****.**');
             $this->mailer->send($message);
             echo 'ODESLANO';
             exit;
         } catch (\Nette\Mail\SmtpException $e) {
             echo 'NEODESLANO';
             exit;
         }
     }
 }