-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Add support for multiple mailers #33409
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
4e8d20a
to
356436f
Compare
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridTransportFactoryTest.php
Outdated
Show resolved
Hide resolved
2a9323a
to
5dfe3b5
Compare
You wrote mailgun instead of important in the PR header example code |
5dfe3b5
to
99786d7
Compare
@OskarStark fixed :) |
6dc2765
to
e929ee8
Compare
is this convention sensible? should we support an explicit option? i.e. default_transport: some |
Yes much better, doctrine or messenger are doing the same 👍 |
In which case this convention would be a problem? The sort does not matter except for the first one which is the default. Less configuration is better, right? |
so the sorting matters :)
yes :) but im not sure we should ignore the configuration part in "convention over configuration" otherwise it's just a magic convention. |
I fail to see the magic here. The first one is the default one. That's all. |
both work :) it's a doc issue eventually. To me the magic is, updating the ordering (i.e. to "alpha order") might change the default implicitly. however, that's the case anyway as long as someone relies on the "first is default" convention, without knowing about Let's keep it simple then 👍 |
note the messenger section does enforce 100% explicit configuration: symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php Lines 1129 to 1130 in bcb91ea
|
7483aeb
to
695a33a
Compare
New (simpler/better?) implementation without BC breaks. |
57faca6
to
ecc7898
Compare
ecc7898
to
de5fae4
Compare
This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] Add support for multiple mailers | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | closes #32535 | License | MIT | Doc PR | - This adds the possibility to define several email transports. If you only have one email transport, nothing changes: ```yaml framework: mailer: dsn: '%env(MAILER_DSN)%' ``` But if you need more than one, use the `transports` entry instead: ```yaml framework: mailer: transports: main: '%env(MAILER_DSN)%' important: '%env(MAILER_DSN_IMPORTANT)%' ``` Then, when sending an email via the `Mailer`, pass the mailer name explicitly (by default, the first one is used): ```php // use the first "main" transport $mailer->send($email); // or use the "important" one (`null` is the envelope) $mailer->send($email, null, 'important'); ``` The web profiler now displays the name and the shorten DSN. Commits ------- de5fae4 [Mailer] Add support for multiple mailers
This PR was squashed before being merged into the 4.4 branch (closes #12422). Discussion ---------- [Mailer] Add support for multiple mailers #12259 and symfony/symfony#33409 ~~Do we need a `versionadded:: 4.4`?~~  Commits ------- aeedbd2 [Mailer] Add support for multiple mailers
This adds the possibility to define several email transports.
If you only have one email transport, nothing changes:
But if you need more than one, use the
transports
entry instead:Then, when sending an email via the
Mailer
, pass the mailer name explicitly (by default, the first one is used):The web profiler now displays the name and the shorten DSN.