'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->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; } }