yii2 mailer mail not sent

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


yii2 mailer mail not sent



There are absolutely two identical methods for sending mail (registration of a new user, sending a letter to activate the user). One method is implemented in the console, and it works:


public function actionSendMessage()
{
$user = new User();
$this->readValue($user, 'username');
$this->readValue($user, 'login');
$this->readValue($user, 'email');
$user->hash_password = Yii::$app->getSecurity()->generatePasswordHash($this->prompt('password'));
$this->readValue($user, 'phone');
$this->readValue($user, 'address');;
$user->state = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
Yii::$app->mailer->compose('@app/mail/emailConfirm', ['user' => $user])
->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
->setTo($user->email)
->setSubject('Email confirmation for ' . Yii::$app->name)
->send();
}
}



The second must send a letter when registering on the site, but alas, the letter does not come (no errors):


public function sign()
{

$user = new User();
$user->username = $this->username;
$user->login = $this->login;
$user->email = $this->email;
$user->hash_password = yii::$app->security->generatePasswordHash($this->password);
$user->phone = $this->phone;
$user->address = $this->address;
$user->state = User::STATUS_WAIT;
$user->generateAuthKey();
$user->generateEmailConfirmToken();
if ($user->save()) {
Yii::$app->mailer->compose('@app/mail/emailConfirm', ['user' => $user])
->setFrom([Yii::$app->params['supportEmail'] => Yii::$app->name])
->setTo($user->email)
->setSubject('Email confirmation for ' . Yii::$app->name)
->send();
}

}



In what there can be an error? $user->save() is work for both actions.


$user->save()









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

F7,8F0wFE,L1q3QbsUZ7yKaVFvMM ojlGTQXWZs,Z,E K Zy xyfF64MR ouW 9 E
QN,qE5Q C,D1un JHh bGyULy4lQB,o,aP

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham