-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Templated email messages fails when sending async #39190
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
Comments
What is the intended behaviour when queueing template messages, doing the rendering before enqueuing the message for async sending, OR just before actually sending the message to the mailer transport? In other words, is rendering intended to be done before dispatching to the messenger's bus? |
@ronnylt your test is created its own mailer without wiring the event dispatcher with the BodyRendererListener. So your test mailer does not configure support for templates. You should be using the Mailer service defined by FrameworkBundle with the full config |
I am currently trying to implement templated emails in an application using Symfony components w/o the framework and I am experiencing the same bug. Looking at the code in Mailer.php: The bug was introduced by commit fc4be48 trying to fix duplicate events being dispatched due to commit 829566c. I am not 100% into the Symfony architecture and configuration but I wonder how anyone is still able to send templated emails since their email will never be dispatched on the message bus with the rendered body. |
Hey, thanks for your report! |
Just a quick reminder to make a comment on this. If I don't hear anything I'll close this. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
See #47049 where we now throw a better error message to help debugging such errors. |
Symfony version(s) affected: 5.x
Description
When sending a
TemplatedEmail
asynchronously, an exception is thrown :Symfony\Component\Mime\Exception\LogicException: A message must have a text or an HTML part or attachments.
.The rendering of the templated is not done, as it's deferred to the actual email sending, but when the messenger's message is created it fails:
How to reproduce
With a the following test, or by sending async templated messages as documented here: https://symfony.com/doc/current/mailer.html#sending-messages-async
The text was updated successfully, but these errors were encountered: