-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Add support for allowing some users even if recipients
is defined in EnvelopeListener
#54044
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
Conversation
4f9a277
to
876707a
Compare
src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php
Outdated
Show resolved
Hide resolved
876707a
to
83cc068
Compare
src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php
Outdated
Show resolved
Hide resolved
83cc068
to
82ab4e4
Compare
I don't understand what's this for, can you please give me a few examples ? The code is fairly intricated for only two options and I'm wondering how this logic is sensible for real world use cases. 🙏 |
Sure, here is the documentation And our real world example is for the preproduction: mailer_recipients: [ '[email protected]' ]
mailer_recipients_allowed: [ '/@jolicode\.com$/', '/^foobar@example\.com$/', '/^baz@example\.com$/' ] TL;DR: in preprod, we want that all mails to be sent to |
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Show resolved
Hide resolved
src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php
Outdated
Show resolved
Hide resolved
82ab4e4
to
adf6d45
Compare
I added some tests for the DIC part. But the configuration was broken in XML. I need #54292 first to be merged |
adf6d45
to
ef69bed
Compare
This PR was merged into the 5.4 branch. Discussion ---------- [FrameworkBundle] Fix mailer config with XML | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | | License | MIT I noticed that, while adding test for #54044 --- Before my patch, if I keep only one recipients: ``` >…ome/gregoire/dev/github.com/lyrixx/symfony(5.4 *) git di diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml index be53f59..5ccdefaf32 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_dsn.xml @@ -11,7 +11,7 @@ <framework:envelope> <framework:sender>[email protected]</framework:sender> <framework:recipients>[email protected]</framework:recipients> - <framework:recipients>[email protected]</framework:recipients> + <!-- <framework:recipients>[email protected]</framework:recipients> --> </framework:envelope> <framework:header name="from">[email protected]</framework:header> <framework:header name="bcc">[email protected]</framework:header> >…ome/gregoire/dev/github.com/lyrixx/symfony(5.4 *) ./phpunit src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/XmlFrameworkExtensionTest.php --filter 'testMailer#0' PHPUnit 9.6.16 by Sebastian Bergmann and contributors. Warning: Your XML configuration validates against a deprecated schema. Suggestion: Migrate your XML configuration using "--migrate-configuration"! Testing Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\XmlFrameworkExtensionTest E 1 / 1 (100%)R Time: 00:00.103, Memory: 21.88 MB There was 1 error: 1) Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\XmlFrameworkExtensionTest::testMailer with data set #0 ('mailer_with_dsn', array('smtp://example.com')) Symfony\Component\Config\Definition\Exception\InvalidTypeException: Invalid type for path "framework.mailer.envelope.recipients". Expected "array", but got "string" ``` And I cannot add more XML configuration, without this patch Commits ------- 0cfdf2f [FrameworkBundle] Fix mailer config with XML
ef69bed
to
7661e81
Compare
I have rebased, now the PR is to merge |
22d2b54
to
331438d
Compare
src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php
Outdated
Show resolved
Hide resolved
331438d
to
694863f
Compare
src/Symfony/Component/Mailer/EventListener/EnvelopeListener.php
Outdated
Show resolved
Hide resolved
694863f
to
9139712
Compare
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mailer_with_dsn.php
Outdated
Show resolved
Hide resolved
...ony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mailer_with_transports.xml
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Mailer/Tests/EventListener/EnvelopeListenerTest.php
Show resolved
Hide resolved
9139712
to
41d542b
Compare
@nicolas-grekas I have addressed your comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyrixx We should probably add an entry in the framework bundle changelog as well like:
* Add the `allowed_recipients` option for mailer to allow some users to receive emails even if `recipients` is defined.
…defined in `EnvelopeListener`
41d542b
to
6228896
Compare
@fabpot thanks. Added (+ rebased) |
Thank you @lyrixx. |
I'm migrate an application from SwiftMailer to symfony/mailer, and this options was used.
depends on #54292