【问题标题】:how to use Swift_Plugins_AntiFloodPlugin in yii2如何在 yii2 中使用 Swift_Plugins_AntiFloodPlugin
【发布时间】:2016-09-30 02:22:17
【问题描述】:

我正在发送大约 3000 封带有附件的电子邮件。出于这个原因,我正在使用 swift mailers AntiFlood 和 Throttler 插件。但我收到以下错误:

异常 'yii\base\UnknownPropertyException' 带有消息 'Setting unknown property: yii\swiftmailer\Mailer::plugins'

这是我添加插件的 main-local.php。

        'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        'viewPath' => '@common/mail',
        // 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' => false,
        'transport' => [
                            'class'         => 'Swift_SmtpTransport',
                            'host'          => 'mail.test.com',
                            'username'      => 'noreply@test.com',
                            'password'      => 'welcome@123',
                            'port'          => '25',
                            //'encryption'    => 'tls',
                        ],
        'plugins'=> [
                        [
                            'class' => 'Swift_Plugins_ThrottlerPlugin',
                            'constructArgs' => ['20'],
                        ],
                        [
                             'class' => 'Swift_Plugins_AntiFloodPlugin',
                             'constructArgs' => [30,45],
                        ],
                    ],
    ],

谢谢

【问题讨论】:

    标签: php yii2 swiftmailer


    【解决方案1】:

    here 所述,plugins 键应在transport 内:

    'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        'viewPath' => '@common/mail',
        'useFileTransport' => false,
        'transport' => [
            'class'         => 'Swift_SmtpTransport',
            'host'          => 'mail.test.com',
            'username'      => 'noreply@test.com',
            'password'      => 'welcome@123',
            'port'          => '25',
            'plugins'=> [
                [
                    'class' => 'Swift_Plugins_ThrottlerPlugin',
                    'constructArgs' => ['20'],
                ],
                [
                    'class' => 'Swift_Plugins_AntiFloodPlugin',
                    'constructArgs' => [30,45],
                ],
            ],
        ],
    ],
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-18
      • 2015-08-29
      • 2014-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多