Config mail.ru smtp

This commit is contained in:
iIronside
2023-10-18 10:48:38 +03:00
parent 5469a209a5
commit 233a8a6d10
9 changed files with 53 additions and 20 deletions

View File

@ -59,7 +59,29 @@ class SignupForm extends Model
$auth = Yii::$app->authManager;
$authorRole = $auth->getRole('user');
$auth->assign($authorRole, $user->id);
return $user->save() ? $user : null;
if ($user->save()) {
$this->sendEmail($user);
return $user;
} else {
return null;
}
}
/**
* Sends an email with a link, for resetting the password.
*
* @return bool whether the email was send
*/
private function sendEmail(User $user)
{
return Yii::$app->mailer->compose(
['html' => 'signup-html', 'text' => 'signup-text'],
['user' => $this]
)
->setFrom([Yii::$app->params['senderEmail'] => Yii::$app->name . ' robot'])
->setTo($user->email)
->setSubject('Account registration at ' . Yii::$app->name)
->send();
}
}