Skip to content

Commit d68d800

Browse files
committed
Merge branch '5.0'
* 5.0: moving mailer transport section
2 parents b8cbc27 + 9e233ec commit d68d800

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

mailer.rst

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object::
119119
->subject('Time for Symfony Mailer!')
120120
->text('Sending emails is fun again!')
121121
->html('<p>See Twig integration for better HTML integration!</p>');
122-
122+
123123
$mailer->send($email);
124124

125125
// ...
@@ -644,6 +644,32 @@ and it will select the appropriate certificate depending on the ``To`` option::
644644
$firstEncryptedEmail = $encrypter->encrypt($firstEmail);
645645
$secondEncryptedEmail = $encrypter->encrypt($secondEmail);
646646

647+
Multiple Email Transports
648+
-------------------------
649+
650+
You may want to use more than one mailer transport for delivery of your messages.
651+
This can be configured by replacing the ``dsn`` configuration entry with a
652+
``transports`` entry, like:
653+
654+
.. code-block:: yaml
655+
656+
# config/packages/mailer.yaml
657+
framework:
658+
mailer:
659+
transports:
660+
main: '%env(MAILER_DSN)%'
661+
alternative: '%env(MAILER_DSN_IMPORTANT)%'
662+
663+
By default the first transport is used. The other transports can be used by
664+
adding a text header ``X-Transport`` to an email::
665+
666+
// Send using first "main" transport ...
667+
$mailer->send($email);
668+
669+
// ... or use the "alternative" one
670+
$email->getHeaders()->addTextHeader('X-Transport', 'alternative');
671+
$mailer->send($email);
672+
647673
Sending Messages Async
648674
----------------------
649675

@@ -705,32 +731,6 @@ you have a transport called ``async``, you can route the message there:
705731
Thanks to this, instead of being delivered immediately, messages will be sent to
706732
the transport to be handled later (see :ref:`messenger-worker`).
707733

708-
Multiple Email Transports
709-
-------------------------
710-
711-
You may want to use more than one mailer transport for delivery of your messages.
712-
This can be configured by replacing the ``dsn`` configuration entry with a
713-
``transports`` entry, like:
714-
715-
.. code-block:: yaml
716-
717-
# config/packages/mailer.yaml
718-
framework:
719-
mailer:
720-
transports:
721-
main: '%env(MAILER_DSN)%'
722-
important: '%env(MAILER_DSN_IMPORTANT)%'
723-
724-
By default the first transport is used. The other transports can be used by
725-
adding a text header ``X-Transport`` to an email::
726-
727-
// Send using first "main" transport ...
728-
$mailer->send($email);
729-
730-
// ... or use the "important" one
731-
$email->getHeaders()->addTextHeader('X-Transport', 'important');
732-
$mailer->send($email);
733-
734734
Adding Tags and Metadata to Emails
735735
----------------------------------
736736

0 commit comments

Comments
 (0)