Example #1
0
 public static function emailHandler($to = FALSE)
 {
     try {
         if (!$to) {
             $to = Helper::getSiteConfig()->contactinfo->siteMail->value;
         }
         if (empty(self::$data)) {
             throw new Exception('Класс не инициализирован должным образом');
         }
         self::emailSender((string) $to, self::$data['subject'], self::$data['message'], self::$data['email']);
         return TRUE;
     } catch (Exception $ex) {
         Session::setUserMsg('Пожалуйста, заполните все поля формы', 'danger');
         header('Location: ' . $_SERVER['REQUEST_URI']);
     }
 }
 public function indexAction()
 {
     $fc = FrontController::getInstance();
     $model = new FrontModel();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         Mailer::setData($_POST);
         if (Mailer::emailHandler()) {
             Session::setUserMsg('Ваше сообщение успешно отправлено. Мы свяжемся с вами в ближайшее время', 'success');
             header('Location: ' . $_SERVER['REQUEST_URI']);
             exit;
         }
     } else {
         $output = $model->render('../views/contacts/contacts.php', 'withoutSliderAndSidebar');
         $fc->setPage($output);
     }
 }