Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions more-with-symfony/en/04-Emails.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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(new 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
Expand Down