Alesh
Alesh

Reputation: 341

how can we implement password-recovery by email in yii 2

I tried to do some changes in common/config/main-local.php

'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.mailtrap.io',
                'username' => '[email protected]',
                'password' => '***************',
                'port' => '2525',
                'encryption' => 'tls',
            ],
        ],

Upvotes: 0

Views: 265

Answers (1)

Yerke
Yerke

Reputation: 2235

Maybe some of your transport settings are incorrect, so it cannot send an email. For local server you can just set useFileTransport to true like:

'mailer' => [
    'class' => 'yii\swiftmailer\Mailer',
    // send all mails to a file by default. You have to set
    // 'useFileTransport' to false and configure a transport
    // for the mailer to send real emails.
    'useFileTransport' => true,
],

Then check your <app>/runtime/mail/folder, where *.eml mail will be generated. Therefore you can click on your password-recovery link and proceed futher.

P.S. Yii2 advanced template includes email password-recovery feature from the box (if you are implementing it from scratch)

Upvotes: 1

Related Questions