'trim'], ['email', 'required'], ['email', 'email'], ['email', 'exist', 'targetClass' => '\common\logic\User\User\Model\User', 'message' => 'There is no user with such email.' ], ]; } /** * Sends an email with a link, for resetting the password. * * @return boolean whether the email was send */ public function sendEmail() { $userModule = UserModule::getInstance(); $user = User::findOne([ 'email' => $this->email, ]); if ($user) { if (!$userModule->isPasswordResetTokenValid($user->password_reset_token)) { $userModule->generatePasswordResetToken($user); } if ($user->save()) { return \Yii::$app->mailerService->sendFromSite( 'Mot de passe oublié', 'passwordResetToken', ['user' => $user], $this->email ); } } return false; } }