8000 [Mailer] Add a comment to avoid the same wrong PR over and over again by fabpot · Pull Request #47052 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Mailer] Add a comment to avoid the same wrong PR over and over again #47052

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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Symfony/Component/Mailer/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function send(RawMessage $message, Envelope $envelope = null): void
}

if (null !== $this->dispatcher) {
// The dispatched event here has `queued` set to `true`; the goal is NOT to render the message, but to let
// listeners do something before a message is sent to the queue.
// We are using a cloned message as we still want to dispatch the **original** message, not the one modified by listeners.
// That's because the listeners will run again when the email is sent via Messenger by the transport (see `AbstractTransport`).
// Listeners should act depending on the `$queued` argument of the `MessageEvent` instance.
$clonedMessage = clone $message;
$clonedEnvelope = null !== $envelope ? clone $envelope : Envelope::create($clonedMessage);
$event = new MessageEvent($clonedMessage, $clonedEnvelope, (string) $this->transport, true);
Expand Down
0