From 98b8ecc7110f882a692bce9b65502c5c580fb927 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 11 Jan 2014 18:05:52 +0100 Subject: [PATCH] document the ability to configure more than one mailer at the same time --- reference/configuration/swiftmailer.rst | 65 +++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/reference/configuration/swiftmailer.rst b/reference/configuration/swiftmailer.rst index a161d510724..ee6c625b5cc 100644 --- a/reference/configuration/swiftmailer.rst +++ b/reference/configuration/swiftmailer.rst @@ -11,6 +11,9 @@ options, see `Full Default Configuration`_ The ``swiftmailer`` key configures Symfony's integration with Swift Mailer, which is responsible for creating and delivering email messages. +The following section lists all options that are available to configure a +mailer. It is also possible to configure several mailers (see `Using Multiple Mailers`_). + Configuration ------------- @@ -220,3 +223,65 @@ Full Default Configuration threshold="99" /> + +Using Multiple Mailers +---------------------- + +You can configure multiple mailers by grouping them under the ``mailers`` +key (the default mailer is identified by the ``default_mailer`` option): + +.. configuration-block:: + + .. code-block:: yaml + + swiftmailer: + default_mailer: second_mailer + mailers: + first_mailer: + # ... + second_mailer: + # ... + + .. code-block:: xml + + + + + + + + + + .. code-block:: php + + $container->loadFromExtension('swiftmailer', array( + 'default_mailer' => 'second_mailer', + 'mailers' => array( + 'first_mailer' => array( + // ... + ), + 'second_mailer' => array( + // ... + ), + ), + )); + +Each mailer is registered as a service:: + + // ... + + // returns the first mailer + $container->get('swiftmailer.mailer.first_mailer'); + + // also returns the second mailer since it is the default mailer + $container->get('swiftmailer.mailer'); + + // returns the second mailer + $container->get('swiftmailer.mailer.second_mailer');