Common -- & amp; gt; config -- & amp; gt; main. php settings, code: {code ...} code in PasswordResetRequestForm: {code ...} however, you can use the following method to receive the sent Email {code ...} // common --> config --> main. php settings, code:
'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => FALSE, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.exmail.qq.com', 'username' => 'serviceEmail', 'password' => 'emailPassword', 'port' => '465', 'encryption' => 'ssl', ], ],
// The code in PasswordResetRequestForm:
public function sendEmail(){ /* @var $user User */ $user = User::findOne([ 'status' => User::STATUS_ACTIVE, 'email' => $this->email, ]); if ($user) { if (!User::isPasswordResetTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); } if ($user->save()) { return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user]) ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) ->setTo($this->email) ->setSubject('Password reset for ' . \Yii::$app->name) ->send(); } } return false;}
// However, you can receive the sent email using the following methods:
Public function actionMailws () {if (\ Yii: $ app-> mailer-> compose ()-> setFrom ('serviceemail')-> setTo ('testemail ') -> setSubject ('hahahahahahaha')-> send () {return TRUE;} else {return FALSE;} Can someone explain how to retrieve the email password?
Reply content:
// Set common --> config --> main. php with the code:
'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => FALSE, 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.exmail.qq.com', 'username' => 'serviceEmail', 'password' => 'emailPassword', 'port' => '465', 'encryption' => 'ssl', ], ],
// The code in PasswordResetRequestForm:
public function sendEmail(){ /* @var $user User */ $user = User::findOne([ 'status' => User::STATUS_ACTIVE, 'email' => $this->email, ]); if ($user) { if (!User::isPasswordResetTokenValid($user->password_reset_token)) { $user->generatePasswordResetToken(); } if ($user->save()) { return \Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user]) ->setFrom([\Yii::$app->params['supportEmail'] => \Yii::$app->name . ' robot']) ->setTo($this->email) ->setSubject('Password reset for ' . \Yii::$app->name) ->send(); } } return false;}
// However, you can receive the sent email using the following methods:
Public function actionMailws () {if (\ Yii: $ app-> mailer-> compose ()-> setFrom ('serviceemail')-> setTo ('testemail ') -> setSubject ('hahahahahahaha')-> send () {return TRUE;} else {return FALSE;} Can someone explain how to retrieve the email password?
You can take a look at this tutorial. I have succeeded in using the above description. 163 does not need any settings, and other mailboxes seem to have to enable smtp, etc.
Mailbox function settings