Skip to content

Add mailer in framework config reference #14087

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions mailer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,8 @@ and it will select the appropriate certificate depending on the ``To`` option::
$firstEncryptedEmail = $encrypter->encrypt($firstEmail);
$secondEncryptedEmail = $encrypter->encrypt($secondEmail);

.. _multiple-email-transports:

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

Expand Down
100 changes: 99 additions & 1 deletion reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ Configuration

* :ref:`name <reference-lock-resources-name>`

* `mailer`_

* :ref:`dsn <mailer-dsn>`
* `transports`_
* `envelope`_

* `sender`_
* `recipients`_

* `php_errors`_

* `log`_
Expand All @@ -159,7 +168,7 @@ Configuration
* `profiler`_

* `collect`_
* `dsn`_
* :ref:`dsn <profiler-dsn>`
* :ref:`enabled <reference-profiler-enabled>`
* `only_exceptions`_
* `only_master_requests`_
Expand Down Expand Up @@ -1075,6 +1084,8 @@ only_master_requests
When this is set to ``true``, the profiler will only be enabled on the master
requests (and not on the subrequests).

.. _profiler-dsn:

dsn
...

Expand Down Expand Up @@ -2932,6 +2943,93 @@ Name of the lock you want to create.
decorates: lock.invoice.store
arguments: ['@lock.invoice.retry_till_save.store.inner', 100, 50]

mailer
~~~~~~

.. _mailer-dsn:

dsn
...

**type**: ``string``

The DSN used by the mailer. When several DSN may be used, use `transports` (see below) instead.

transports
..........

**type**: ``array``

A :ref:`list of DSN <multiple-email-transports>` that can be used by the mailer. A transport name is the key and the dsn is the value.

envelope
........

sender
""""""

**type**: ``string``

Sender used by the `Mailer`. Keep in mind that this setting override a sender set in the code.

recipients
""""""""""

**type**: ``array``

Recipients used by the `Mailer`. Keep in mind that this setting override recipients set in the code.

.. configuration-block::

.. code-block:: yaml

# config/packages/mailer.yaml
framework:
mailer:
dsn: 'smtp://localhost:25'
envelope:
recipients: ['admin@symfony.com', 'lead@symfony.com']

.. code-block:: xml

<!-- config/packages/mailer.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:mailer dsn="smtp://localhost:25">
<framework:envelope>
<framework:recipients>admin@symfony.com</framework:recipients>
<framework:recipients>lead@symfony.com</framework:recipients>
</framework:envelope>
</framework:mailer>
</framework:config>
</container>

.. code-block:: php

// config/packages/mailer.php
namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', [
'mailer' => [
'dsn' => 'smtp://localhost:25',
'envelope' => [
'recipients' => [
'admin@symfony.com',
'lead@symfony.com'
]
]
]
]);
};

workflows
~~~~~~~~~

Expand Down