'\artbox\order\models\Customer', 'filter' => [ 'status' => Customer::STATUS_ACTIVE ], 'message' => 'There is no user with this email address.', ], ]; } /** * Sends an email with a link, for resetting the password. * * @return bool whether the email was send */ public function sendEmail() { $mailer = \Yii::$app->get('smtpmailer'); /* @var $user Customer */ $user = Customer::findOne( [ 'status' => Customer::STATUS_ACTIVE, 'email' => $this->email, ] ); if (!$user) { return false; } if (!Customer::isPasswordResetTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); if (!$user->save()) { return false; } } return $mailer->compose( [ 'html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text', ], [ 'user' => $user ] ) ->setFrom([ Yii::$app->params[ 'supportEmail' ] => Yii::$app->name . ' robot' ]) ->setTo($this->email) ->setSubject('Password reset for ' . Yii::$app->name) ->send(); } }