8000 [Mailer] Add a comment to avoid the same wrong PR over and over again · symfony/symfony@c695695 · GitHub
[go: up one dir, main page]

Skip to content

Commit c695695

Browse files
committed
[Mailer] Add a comment to avoid the same wrong PR over and over again
1 parent 8e34f9a commit c695695

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Symfony/Component/Mailer/Mailer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function send(RawMessage $message, Envelope $envelope = null): void
4848
}
4949

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

0 commit comments

Comments
 (0)
0