Skip to content

Moving mailer transport section #13495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2020
Merged
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
60 changes: 30 additions & 30 deletions mailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,36 @@ and it will select the appropriate certificate depending on the ``To`` option::
$firstEncryptedEmail = $encrypter->encrypt($firstEmail);
$secondEncryptedEmail = $encrypter->encrypt($secondEmail);

Multiple Email Transports
-------------------------

.. versionadded:: 4.4

The option to define multiple email transports was introduced in Symfony 4.4.

You may want to use more than one mailer transport for delivery of your messages.
This can be configured by replacing the ``dsn`` configuration entry with a
``transports`` entry, like:

.. code-block:: yaml

# config/packages/mailer.yaml
framework:
mailer:
transports:
main: '%env(MAILER_DSN)%'
alternative: '%env(MAILER_DSN_IMPORTANT)%'

By default the first transport is used. The other transports can be used by
adding a text header ``X-Transport`` to an email::

// Send using first "main" transport ...
$mailer->send($email);

// ... or use the "alternative" one
$email->getHeaders()->addTextHeader('X-Transport', 'alternative');
$mailer->send($email);

Sending Messages Async
----------------------

Expand Down Expand Up @@ -719,36 +749,6 @@ you have a transport called ``async``, you can route the message there:
Thanks to this, instead of being delivered immediately, messages will be sent to
the transport to be handled later (see :ref:`messenger-worker`).

Multiple Email Transports
-------------------------

.. versionadded:: 4.4

The option to define multiple email transports was introduced in Symfony 4.4.

You may want to use more than one mailer transport for delivery of your messages.
This can be configured by replacing the ``dsn`` configuration entry with a
``transports`` entry, like:

.. code-block:: yaml

# config/packages/mailer.yaml
framework:
mailer:
transports:
main: '%env(MAILER_DSN)%'
important: '%env(MAILER_DSN_IMPORTANT)%'

By default the first transport is used. The other transports can be used by
adding a text header ``X-Transport`` to an email::

// Send using first "main" transport ...
$mailer->send($email);

// ... or use the "important" one
$email->getHeaders()->addTextHeader('X-Transport', 'important');
$mailer->send($email);

Development & Debugging
-----------------------

Expand Down