To provide some additional context to the OP's answer.
As of Symfony 2.3 in the SwiftmailerBundle CompilerPass process it performs the following.
$mailers = $container->getParameter('swiftmailer.mailers');
foreach ($mailers as $name => $mailer) {
$plugins = $container->findTaggedServiceIds(sprintf('swiftmailer.%s.plugin', $name));
foreach ($plugins as $id => $args) {
$transport->addMethodCall('registerPlugin', [new Reference($id)]);
}
}
Based on this you would need to add all of the mailer names to your tags that you would like to add the plugin to, in the format of swiftmailer.%mailer_name%.plugin
. Replacing %mailer_name%
with the name of your mailers.
When not using the multiple mailers
configuration for swiftmailer the %mailer_name%
is default
which is set in the Bundle Configuration.
$v['default_mailer'] = isset($v['default_mailer']) ? (string) $v['default_mailer'] : 'default';
$v['mailers'] = array($v['default_mailer'] => $mailer);
Example config.yml
swiftmailer:
default_mailer: first_mailer #alias: default
mailers:
first_mailer:
#...
second_mailer:
#...
services:
#...
swiftmailer.plugin.array_logger:
class: Swift_Plugins_Loggers_ArrayLogger
swiftmailer.plugin.logger:
class: Swift_Plugins_LoggerPlugin
arguments: ['@swiftmailer.plugin.array_logger']
tags:
- { name: swiftmailer.default.plugin }
- { name: swiftmailer.second_mailer.plugin }
php app/console container:debug
– Vinyl