【问题标题】:How to setup mail folder path in Yii2 framework如何在 Yii2 框架中设置邮件文件夹路径
【发布时间】:2021-05-21 09:28:33
【问题描述】:

我安装了 yiisoft/yii2-app-advanced。有三个主要文件夹 - common、frontend、backend。电子邮件文件夹位于 common/mail 文件夹中。如果我尝试从注册用户的前端控制器发送电子邮件,则会引发错误:

视图文件不存在: C:\wamp64-3-2-0\www\yii2\frontend/mail\emailVerify-html.php

注册是通过控制台命令生成的。但很明显邮件文件夹的路径是错误的。我通过

找到了解决方法
\Yii::$app->mailer->htmlLayout = '@common/mail/layouts/html';
\Yii::$app->mailer->textLayout = '@common/mail/layouts/text';

但它看起来不是很好。是否可以在配置文件中进行设置?希望如此。谢谢。

【问题讨论】:

    标签: php email path yii2


    【解决方案1】:

    所以我发现配置文件中有一个名为 viewPath 的选项,文档中没有提到。

        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'encryption' => 'tls',
                'host' => 'localhost',
                'port' => '587',
                'username' => 'your_username',
                'password' => 'your_password',
            ],
        ],
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-16
    相关资源
    最近更新 更多