drq1257
2017-06-10 18:35
浏览 106
已采纳

我们如何在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' => 'example@examplemail.com',
                'password' => '***************',
                'port' => '2525',
                'encryption' => 'tls',
            ],
        ],

图片转代码服务由CSDN问答提供 功能建议

我试图在common / config / main-local.php中进行一些更改

 'mailer'=>  [
'class'=>  'yii \ swiftmailer \ Mailer',
'transport'=>  [
'class'=>  'Swift_SmtpTransport',
'host'=>  'smtp.mailtrap.io',
'用户名'=>  'example@examplemail.com',
'密码'=>  '***************',
'port'=>  '2525',
'加密'=>  'tls',
],
],
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douhuai2861 2017-06-11 10:14
    已采纳

    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)

    打赏 评论

相关推荐 更多相似问题