diff --git a/mailer.rst b/mailer.rst index 025a5c43813..ebf79865a72 100644 --- a/mailer.rst +++ b/mailer.rst @@ -29,11 +29,58 @@ over SMTP by configuring the DSN in your ``.env`` file (the ``user``, # .env MAILER_DSN=smtp://user:pass@smtp.example.com:port +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/mailer.yaml + framework: + mailer: + dsn: '%env(MAILER_DSN)%' + + .. code-block:: xml + + + + + + + + + + .. code-block:: php + + // config/packages/mailer.php + use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; + return static function (ContainerConfigurator $containerConfigurator): void { + $containerConfigurator->extension('framework', [ + 'mailer' => [ + 'dsn' => '%env(MAILER_DSN)%', + ] + ]); + }; + .. caution:: If you are migrating from Swiftmailer (and the Swiftmailer bundle), be warned that the DSN format is different. +Using built-in transports +~~~~~~~~~~~~~~~~~~~~~~~~~ + +============ ==================================== =========== +DSN protocol Example Description +============ ==================================== =========== +smtp smtp://user:pass@smtp.example.com:25 Mailer uses an SMTP server to send emails +sendmail sendmail://default Mailer uses the local sendmail binary to send emails +============ ==================================== =========== + + Using a 3rd Party Transport ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -822,6 +869,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 ------------------------- diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index cd76b908c64..255adc11fec 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -98,7 +98,7 @@ Configuration * `cafile`_ * `capath`_ * `ciphers`_ - * `headers`_ + * :ref:`headers ` * `http_version`_ * `local_cert`_ * `local_pk`_ @@ -126,7 +126,7 @@ Configuration * `cafile`_ * `capath`_ * `ciphers`_ - * `headers`_ + * :ref:`headers ` * `http_version`_ * `local_cert`_ * `local_pk`_ @@ -151,6 +151,17 @@ Configuration * :ref:`name ` +* `mailer`_ + + * :ref:`dsn ` + * `transports`_ + * `envelope`_ + + * `sender`_ + * `recipients`_ + + * :ref:`headers ` + * `php_errors`_ * `log`_ @@ -159,7 +170,7 @@ Configuration * `profiler`_ * `collect`_ - * `dsn`_ + * :ref:`dsn ` * :ref:`enabled ` * `only_exceptions`_ * `only_master_requests`_ @@ -867,6 +878,8 @@ ciphers A list of the names of the ciphers allowed for the SSL/TLS connections. They can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256'``). +.. _http-headers: + headers ....... @@ -1075,6 +1088,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 ... @@ -2888,6 +2903,101 @@ 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 ` 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 + + + + + + + + admin@symfony.com + lead@symfony.com + + + + + + .. 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', + ] + ] + ] + ]); + }; + +.. _mailer-headers: + +headers +....... + +**type**: ``array`` + +Headers to add to emails. key (``name`` attribute in xml format) +is the header name and value the header value. + workflows ~~~~~~~~~