예제 #1
0
 /**
  * Sends an email to the specified email address using the information collected by this model.
  *
  * @param  string $email the target email address
  *
  * @return boolean whether the model passes validation
  *
  * @throws \cs\web\Exception
  */
 public function send()
 {
     if ($this->validate()) {
         $user = User::find(['email' => $this->email]);
         if (is_null($user)) {
             throw new Exception('Пользователь не найден');
         }
         $fields = \app\services\PasswordRecoverDispatcher::insert($user->getId());
         \cs\Application::mail($this->email, 'Восстановление пароля', 'password_recover', ['user' => $user, 'url' => Url::to(['auth/password_recover_activate', 'code' => $fields['code']], true), 'datetime' => Yii::$app->formatter->asDatetime($fields['date_finish'])]);
         return true;
     } else {
         return false;
     }
 }