YII2 password cannot find emails sent from the server

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.