From 4d519042ec1bd5c988d06e24688dd78475ef7a46 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Mon, 13 Dec 2010 22:00:44 +0100 Subject: [PATCH 1/2] [more with symfony] 04 email --- more-with-symfony/en/04-Emails.markdown | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/more-with-symfony/en/04-Emails.markdown b/more-with-symfony/en/04-Emails.markdown index b2b968f..c9e4ca6 100644 --- a/more-with-symfony/en/04-Emails.markdown +++ b/more-with-symfony/en/04-Emails.markdown @@ -650,6 +650,28 @@ section above): $mailer->registerPlugin($plugin); } +Some plugins should be triggered when the emails are actually sent out +(AntiFlood, BandwithMonitor, Throttler). They should be registered for the +realtime transport only. Otherwise they would be triggered when email is queued +rather than when the queue is flushed. + +In order for those plugins to have the expected behavior, the code below should +always be used to register the plugins when a spool is used. Note than this code +is still valid when the mailer doesn't use a spool. + + [php] + public function configureMailer(sfEvent $event) + { + $mailer = $event->getSubject(); + $transport = $mailer->getRealtimeTransport(); + + $transport->registerPlugin(new Swift_Plugins_ThrottlerPlugin( + 100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE + )); + + $transport->registerPlugin(Swift_Plugins_AntiFloodPlugin(30)); + } + >**TIP** >The ["Plugins"](http://swiftmailer.org/docs/plugins) section of the >Swift Mailer official documentation describes all you need to know about the From 5ee8697602ddc4c2d7596b641ac02b5bd70d237c Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Tue, 14 Dec 2010 22:02:51 +0100 Subject: [PATCH 2/2] fix a typo --- more-with-symfony/en/04-Emails.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/more-with-symfony/en/04-Emails.markdown b/more-with-symfony/en/04-Emails.markdown index c9e4ca6..b9236a9 100644 --- a/more-with-symfony/en/04-Emails.markdown +++ b/more-with-symfony/en/04-Emails.markdown @@ -669,7 +669,7 @@ is still valid when the mailer doesn't use a spool. 100, Swift_Plugins_ThrottlerPlugin::MESSAGES_PER_MINUTE )); - $transport->registerPlugin(Swift_Plugins_AntiFloodPlugin(30)); + $transport->registerPlugin(new Swift_Plugins_AntiFloodPlugin(30)); } >**TIP**