'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() { $userManager = UserManager::getInstance(); $user = User::findOne([ 'email' => $this->email, ]); if ($user) { if (!$userManager->isPasswordResetTokenValid($user->password_reset_token)) { $userManager->generatePasswordResetToken($user); } if ($user->save()) { return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user]) ->setFrom(['contact@opendistrib.net' => 'distrib']) ->setTo($this->email) ->setSubject('[Opendistrib] Mot de passe oublié') ->send(); } } return false; } }