示例#1
0
 /**
  *
  */
 public static function sendEmail($subject, $user_send, $message)
 {
     $config_email = \Kohana::$config->load('email');
     \Email::connect($config_email);
     $from = $config_email->get('admin_email');
     $send = \Email::send($user_send, $from, $subject, $message, $html = true);
 }
示例#2
0
 public function action_forgotPassword()
 {
     if (\Request::current()->is_ajax()) {
         if ($userInfo = User::model()->findByAttributes(['email' => $_POST['params']['email_send']])) {
             $config_email = \Kohana::$config->load('email');
             \Email::connect($config_email);
             $from = $config_email->get('admin_email');
             $subject = 'Password Recovery';
             $to = $_POST['params']['email_send'];
             // ----------Life Time Code
             $code = $this->generatePassword();
             $lifetime = time() + 24 * 60 * 60;
             $userInfo->recovery = $code;
             $userInfo->lifetime = $lifetime;
             $userInfo->save();
             $message = '<strong>Change password Link:</string> <p>
                 <a href="' . \URL::base() . 'auth/recovery/' . $code . '"></a></p>';
             // ----------Life Time
             $send = \Email::send($to, $from, $subject, $message, $html = true);
             $this->response->body(json_encode(['code' => 'Please check your Email!']));
             return;
         } else {
             $this->response->body(json_encode(['code' => 'This Email was not found!']));
             return true;
         }
     }
 }