-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][Mailer] Add a way to configure some email headers from semantic configuration #36736
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
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mailer.yml
Show resolved
Hide resolved
ed6ee44
to
636b293
Compare
636b293
to
80adcc7
Compare
4ff0a6b
to
438eb32
Compare
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.
Thanks :) Here are some things I spotted.
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
438eb32
to
8a6c1dd
Compare
a2851d7
to
7d4cd2f
Compare
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
…rom semantic configuration
7d4cd2f
to
805e9e6
Compare
I don't know if commenting here or opening a new issue is better, but this seems the place closest to the action: I implemented a custom EventSubscriber for the MessageEvent before (currently working in 5.1) but this fails and seems will fail with this PR too in combination with the messenger: Variant A) Then the transport will dispatch the MessageEvent: https://github.com/symfony/mailer/blob/master/Transport/AbstractTransport.php#L61 Everything works as planned. Variant B) The email is than wrapped into a SendEmailMessage which in turn is serialized which eventually calls Symfony\Component\Mime\Message::ensureValidity() which will fail because the message has no FROM header, as the listener could not set it before. -- I think this PR will fail in the same way: The listener cannot set the headers before the message is serialized (because of the mentioned cloning), thus there will be no From header and serialization will fail. Also the Listener cannot replace the previously set placeholder sender address because it uses For me the current behavior in 5.1 would qualify as a bug, as "Instead of calling ->from() every time you create a new email, you can create an event subscriber and listen to the MessageEvent event to set the same From email to all messages." like the documentation states is not working because in combination with the messenger the listener cannot modify the message. I can open a new bug report for this if it helps. Best regards, |
@j-schumann Thanks for the details report. Can you please open a new issue? As the PR here is merged, we won't be able to track your issue properly and it will get lost. |
The configuration allows to set global
sender
andrecipients
, but for the envelope.If you want to set some global headers, it was not possible (a default
from
header for instance, of abcc
).That's implemented in this PR.