Class frontend\models\ResendVerificationEmailForm
| Inheritance | frontend\models\ResendVerificationEmailForm » yii\base\Model |
|---|---|
| Source Code | https://github.com/yiisoft/yii2-app-advanced/blob/master/frontend/models/ResendVerificationEmailForm.php |
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| string | frontend\models\ResendVerificationEmailForm |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| rules() | frontend\models\ResendVerificationEmailForm | |
| sendEmail() | Sends confirmation email to user. | frontend\models\ResendVerificationEmailForm |
Property Details
Method Details
| public rules ( ) |
public function rules(): array
{
return [
['email', 'trim'],
['email', 'required'],
['email', 'email'],
['email', 'exist',
'targetClass' => User::class,
'filter' => ['status' => User::STATUS_INACTIVE],
'message' => 'There is no user with this email address.',
],
];
}
Sends confirmation email to user.
| public boolean sendEmail ( \yii\mail\MailerInterface $mailer, string $supportEmail, string $appName ) | ||
| $mailer | \yii\mail\MailerInterface |
The mailer component. |
| $supportEmail | string |
The support email address. |
| $appName | string |
The application name. |
| return | boolean |
Whether the email was sent. |
|---|---|---|
public function sendEmail(MailerInterface $mailer, string $supportEmail, string $appName): bool
{
$user = User::findOne([
'email' => $this->email,
'status' => User::STATUS_INACTIVE,
]);
if ($user === null) {
return false;
}
return $mailer
->compose(
['html' => 'emailVerify-html', 'text' => 'emailVerify-text'],
['user' => $user],
)
->setFrom([$supportEmail => $appName . ' robot'])
->setTo($this->email)
->setSubject('Account registration at ' . $appName)
->send();
}