drq1257 2017-06-10 18:35 采纳率: 0%
浏览 121
已采纳

我们如何在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',
            ],
        ],
  • 写回答

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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办