Skip to content

[Mime] Change the way we avoid rendering an email twice #47075

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 27, 2022

Conversation

fabpot
Copy link
Member

@fabpot fabpot commented Jul 27, 2022

Q A
Branch? 6.2
Bug fix? yes-ish
New feature? yes-ish
Deprecations? no
Tickets n/a
License MIT
Doc PR symfony/symfony-docs#17065

Trying to kill several birds with one stone here.

I was not very happy with the way we ensured that emails were not renderer more than once.
This solution seems easier and allows for people to render an email before sending it to Messenger (important when you have Doctrine entities in the context for instance) as documented in the related doc PR.

}

$message->context([]);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows a TemplatedEmail to be serialized after rendering the body when the context contains non-serializable variables like Doctrine entities.

@fabpot fabpot merged commit 7940cc4 into symfony:6.2 Jul 27, 2022
@fabpot fabpot deleted the email-rendering-impr branch July 27, 2022 12:43
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Jul 27, 2022
…(fabpot)

This PR was merged into the 6.2 branch.

Discussion
----------

[Mailer] Add more information about sending email async

The example only works as of 6.2 thanks to symfony/symfony#47075

I've written this PR because we keep having issues like symfony/symfony#44439.
So, documenting a bit more how it works internally might help people understand what to do.

Commits
-------

4fbbc16 Add more information about sending email async
@fabpot fabpot mentioned this pull request Oct 24, 2022
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.

4 participants