From f9c53b97e032e7c78c6f02d5e333d1b2702bbb35 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Thu, 11 Apr 2024 11:18:33 +0200 Subject: [PATCH] [Mailer] Add the `allowed_recipients` option --- mailer.rst | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/mailer.rst b/mailer.rst index f32f0ff0cfc..2ce97859b11 100644 --- a/mailer.rst +++ b/mailer.rst @@ -1852,6 +1852,75 @@ a specific address, instead of the *real* address: ; }; +You may also go even further by restricting the recipient to a specific +address, except for some specific ones. This can be done by using the +``allowed_recipients`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/mailer.yaml + when@dev: + framework: + mailer: + envelope: + recipients: ['youremail@example.com'] + allowed_recipients: + - 'interal@example.com' + # you can also use regular expression to define allowed recipients + - 'internal-.*@example.(com|fr)' + + .. code-block:: xml + + + + + + + + + + youremail@example.com + internal@example.com + + internal-.*@example.(com|fr) + + + + + + .. code-block:: php + + // config/packages/mailer.php + use Symfony\Config\FrameworkConfig; + + return static function (FrameworkConfig $framework): void { + // ... + $framework->mailer() + ->envelope() + ->recipients(['youremail@example.com']) + ->allowedRecipients([ + 'internal@example.com', + // you can also use regular expression to define allowed recipients + 'internal-.*@example.(com|fr)', + ]) + ; + }; + +With this configuration, all emails will be sent to ``youremail@example.com``, +except for those sent to ``internal@example.com``, which will receive emails as +usual. + +.. versionadded:: 7.1 + + The ``allowed_recipients`` option was introduced in Symfony 7.1. + Write a Functional Test ~~~~~~~~~~~~~~~~~~~~~~~ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy