Class frontend\models\ResendVerificationEmailForm

Inheritancefrontend\models\ResendVerificationEmailForm » yii\base\Model
Source Code https://github.com/yiisoft/yii2-app-advanced/blob/master/frontend/models/ResendVerificationEmailForm.php

Public Properties

Hide inherited properties

Property Type Description Defined By
$email string frontend\models\ResendVerificationEmailForm

Public Methods

Hide inherited methods

Method Description Defined By
rules() frontend\models\ResendVerificationEmailForm
sendEmail() Sends confirmation email to user frontend\models\ResendVerificationEmailForm

Property Details

Hide inherited properties

$email public property
public string $email null

Method Details

Hide inherited methods

rules() public method

public void rules ( )

                public function rules()
{
    return [
        ['email', 'trim'],
        ['email', 'required'],
        ['email', 'email'],
        ['email', 'exist',
            'targetClass' => '\common\models\User',
            'filter' => ['status' => User::STATUS_INACTIVE],
            'message' => 'There is no user with this email address.'
        ],
    ];
}

            
sendEmail() public method

Sends confirmation email to user

public boolean sendEmail ( )
return boolean

Whether the email was sent

                public function sendEmail()
{
    $user = User::findOne([
        'email' => $this->email,
        'status' => User::STATUS_INACTIVE
    ]);
    if ($user === null) {
        return false;
    }
    return Yii::$app
        ->mailer
        ->compose(
            ['html' => 'emailVerify-html', 'text' => 'emailVerify-text'],
            ['user' => $user]
        )
        ->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name . ' robot'])
        ->setTo($this->email)
        ->setSubject('Account registration at ' . Yii::$app->name)
        ->send();
}