Check my configuration item {code...} And then upload my sending code {code...}. How can I test it? Is my posture incorrect ?! First go to my
Configuration item
'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => true, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => 'username@163.com', 'password' => 'myPassword', 'port' => '994', 'encryption' => 'ssl', ], ],
Then go to mySend code
return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user]) ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) ->setTo($this->email) ->setSubject('Password reset for ' . \Yii::$app->name) ->send();
The test is invalid. Is it me?Posture
No ?!
Reply content:
First go to myConfiguration item
'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => true, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => 'username@163.com', 'password' => 'myPassword', 'port' => '994', 'encryption' => 'ssl', ], ],
Then go to mySend code
return \Yii::$app->mailer->compose('passwordResetToken', ['user' => $user]) ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) ->setTo($this->email) ->setSubject('Password reset for ' . \Yii::$app->name) ->send();
The test is invalid. Is it me?Posture
No ?!
'Usefiletransport '=> true,
Change to false. If it is true, ONLY emails are generated at runtime.
I think Yii2 is not very stable yet. Currently, it cannot be used in the production environment.
It seems that the email address set by \ Yii: $ app-> mailer's setFrom () must be the same as the email address in the configuration.