Skip to content

Commit 736f417

Browse files
committed
minor #12422 [Mailer] Add support for multiple mailers (hiddewie)
This PR was squashed before being merged into the 4.4 branch (closes #12422). Discussion ---------- [Mailer] Add support for multiple mailers #12259 and symfony/symfony#33409 ~~Do we need a `versionadded:: 4.4`?~~ ![image](https://user-images.githubusercontent.com/1073881/66234058-05c5d680-e6ed-11e9-963f-d2a25c508aee.png) Commits ------- aeedbd2 [Mailer] Add support for multiple mailers
2 parents 65105ce + aeedbd2 commit 736f417

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

mailer.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,38 @@ you have a transport called ``async``, you can route the message there:
697697
Thanks to this, instead of being delivered immediately, messages will be sent to
698698
the transport to be handled later (see :ref:`messenger-worker`).
699699

700+
Mutliple email transports
701+
-------------------------
702+
703+
.. versionadded:: 4.4
704+
705+
The option to define multiple email transports was introduced in Symfony 4.4.
706+
707+
You may want to use more than one mailer transport for delivery of your messages.
708+
This can be configured by replacing the ``dsn`` configuration entry with a
709+
``transports`` entry, like:
710+
711+
.. code-block:: yaml
712+
713+
# config/packages/mailer.yaml
714+
framework:
715+
mailer:
716+
transports:
717+
main: '%env(MAILER_DSN)%'
718+
important: '%env(MAILER_DSN_IMPORTANT)%'
719+
720+
By default the first transport is used. The other tranports can be used by adding
721+
a text header ``X-Transport`` to an email:
722+
723+
.. code-block:: php
724+
725+
// Send using first "main" transport ...
726+
$mailer->send($email);
727+
728+
// ... or use the "important" one
729+
$email->getHeaders()->addTextHeader('X-Transport', 'important');
730+
$mailer->send($email);
731+
700732
Development & Debugging
701733
-----------------------
702734

0 commit comments

Comments
 (0)