如何在 yii2 中使用 Swift_Plugins_AntiFloodPlugin
how to use Swift_Plugins_AntiFloodPlugin in yii2
我正在发送大约 3000 封带附件的电子邮件。出于这个原因,我正在使用 swift 邮件程序 AntiFlood 和 Throttler 插件。但我收到以下错误:
异常 'yii\base\UnknownPropertyException' 消息 'Setting unknown property: yii\swiftmailer\Mailer::plugins'
这是我添加插件的主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],
],
],
],
谢谢
如前所述 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],
],
],
],
],
我正在发送大约 3000 封带附件的电子邮件。出于这个原因,我正在使用 swift 邮件程序 AntiFlood 和 Throttler 插件。但我收到以下错误:
异常 'yii\base\UnknownPropertyException' 消息 'Setting unknown property: yii\swiftmailer\Mailer::plugins'
这是我添加插件的主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],
],
],
],
谢谢
如前所述 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],
],
],
],
],