Пример #1
0
 public function passAction($params)
 {
     if ($this->_di->get('request')->isPost()) {
         $restore_email = filter_input(INPUT_POST, 'restore_email');
         $restore_email = filter_var($restore_email, FILTER_VALIDATE_EMAIL);
     }
     switch ($params) {
         case 'restore':
             if (!$restore_email) {
                 $this->error('Where is an e-mail?!');
             }
             $_client = new Clients($this->_di);
             $client = $_client->findClientByEmail($restore_email);
             if (!is_array($client)) {
                 $this->error('Пользователь с таким E-Mail не найден');
                 return false;
             }
             $new_password = $_client->genPassword($this->_di->get('config')->get('app')['password_length_for_generation']);
             if (!$_client->update($client['cid'], array('password' => hash('sha512', $new_password)))) {
                 $this->error('Возникла ошибка при генерации нового пароля. Попробуйте позже или обратитесь к менеджеру');
                 return false;
             }
             $_mailer = new Mail('PHPMailer');
             $config = $this->_di->get('config')->get('app')['pass_recovery_mail'];
             $_mailer->setConfig(array('to' => array(0 => array('address' => $client['email'], 'name' => $client['surname'] . ' ' . $client['name'])), 'from' => $config['from'], 'subject' => $config['subject']));
             $_mailer->setConfig(array('smtp' => $this->_di->get('config')->get('app')['smtp']));
             $this->_di->get('builder')->assign('new_pass', $new_password);
             $_mailer->setBody($this->_di->get('builder')->fetch('layout/emails/pass_recovery.tpl'));
             if ($_mailer->send()) {
                 $this->good_answer('Письмо было отправлено');
                 return false;
             } else {
                 $this->error('Ошибка при отправке письма. Попробуйте позже или обратитесь к менеджеру');
             }
             break;
         default:
             $this->error('Unknown command');
             break;
     }
 }
Пример #2
0
 /**
  * fonction quir genere un mot de passe aleatoire pour le compte spécifié en param
  * @param $id_identite
  */
 public function setReinitialiserMdp($id_identite)
 {
     $dbc = \core\App::getDb();
     $this->getunUser($id_identite);
     if ($this->mail != "" || $this->mail != null) {
         $mdp = ChaineCaractere::random(6);
         $mdp_encode = Encrypt::setEncryptMdp($mdp, $id_identite);
         FlashMessage::setFlash("Mot de passe réinitialisé avec succès ! L'utilisateur à reçu un E-mail avec son nouveau mot de passe", "success");
         $dbc->update("mdp", $mdp_encode)->update("last_change_mdp", date("Y-m-d"))->from("identite")->where("ID_identite", "=", $id_identite)->set();
         $mail = new Mail();
         $mail->setEnvoyerMail("Réinitialisation de votre E-mail effectuée", "Votre mot de passe a été réinitialisé", $this->mail);
     } else {
         FlashMessage::setFlash("le mot de passe de {$this->pseudo} ne peu pas être réinitialisé car il ne possède pas d'E-mail");
         $this->erreur = true;
     }
 }
Пример #3
0
 protected function sendNotification($oid)
 {
     $order = $this->_orders->getItem($oid);
     $order_content = $this->_orders->getOrderContent($oid);
     $client = $this->_client->getItem($order['cid']);
     $_mailer = new Mail('PHPMailer');
     $config = $this->_di->get('config')->get('app')['orders_mail'];
     $_mailer->setConfig(array('to' => array(0 => array('address' => $client['email'], 'name' => $client['surname'] . ' ' . $client['name'])), 'from' => $config['from'], 'subject' => 'Заказ в магазине Autopoisk.pro'));
     $_mailer->setConfig(array('smtp' => $this->_di->get('config')->get('app')['smtp']));
     $this->_di->get('builder')->assign('order', $order);
     $this->_di->get('builder')->assign('order_content', $order_content);
     $_mailer->setBody($this->_di->get('builder')->fetch('layout/emails/new_order_for_client.tpl'));
     $_mailer->send();
     unset($_mailer);
     $_mailer = new Mail('PHPMailer');
     $_mailer->setConfig(array('smtp' => $this->_di->get('config')->get('app')['smtp']));
     $_mailer->setConfig(array('to' => array(0 => $config['to']), 'from' => $config['from'], 'subject' => $config['subject']));
     $this->_di->get('builder')->assign('order', $order);
     $this->_di->get('builder')->assign('client_phone', $client['phone']);
     $this->_di->get('builder')->assign('order_content', $order_content);
     $_mailer->setBody($this->_di->get('builder')->fetch('layout/emails/new_order_for_manager.tpl'));
     $_mailer->send();
 }
Пример #4
0
 public function testMailRun()
 {
     $raw = new Letter();
     $raw->setType('text/plain');
     $raw->setData('This mail was automatically sent running the unit tests of Core without render.');
     $render = new Html($this->letter);
     $html = new Letter();
     $html->setData($render->run(null, ['title' => 'Core Mail', 'custom' => 'This mail was automatically sent running the unit tests of Core with the render.']));
     $attachment = new Attachment('Invoice.pdf');
     $attachment->setType('application/pdf');
     $attachment->setData($this->attachment);
     $mail = new Mail(['*****@*****.**']);
     $mail->setSender('*****@*****.**', 'Developers');
     $mail->setSubject('Core Mail');
     $mail->addLetter($raw);
     $mail->addLetter($html);
     $mail->addAttachment($attachment);
     $mail->run();
 }