Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Mailer] Throw a more specific exception when a BodyRendererInterface is needed but not configured #47049

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

Merged
merged 1 commit into from
Jul 24, 2022

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Jul 24, 2022

Q A
Branch? 6.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets n/a
License MIT
Doc PR n/a

When a BodyRendereInterface is not configured, you get the following error message if sending a TemplatedEmail:

A message must have a text or an HTML part or attachments.

After this PR, you will get a better error message:

You must register a "Symfony\Component\Mime\BodyRendererInterface" when a "Symfony\Bridge\Twig\Mime\TemplatedEmail" instance has a text or HTML template set.

That will help debugging such issues.

@carsonbot carsonbot added this to the 6.2 milestone Jul 24, 2022
@derrabus derrabus changed the title [Mailer] Throw a more specific exception when a BodyRendererInterface is needed by not configured [Mailer] Throw a more specific exception when a BodyRendererInterface is needed but not configured Jul 24, 2022
@fabpot fabpot force-pushed the mailer-more-specific-exception branch from d3eb508 to 60f49fe Compare July 24, 2022 15:38
@fabpot fabpot merged commit 58c50dc into symfony:6.2 Jul 24, 2022
@fabpot fabpot deleted the mailer-more-specific-exception branch July 24, 2022 15:39
@fabpot fabpot mentioned this pull request Oct 24, 2022
fabpot added a commit that referenced this pull request Nov 28, 2022
This PR was merged into the 6.2 branch.

Discussion
----------

[Mailer] Fix body renderer check

| Q             | A
| ------------- | ---
| Branch?       | 6.2
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | n/a <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License       | MIT
| Doc PR        | n/a

What I did in #47049 does not work as one can have many message listeners. So, we need to do this check after all listeners are run.

Commits
-------

8bb7522 [Mailer] Fix body renderer check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants