$stamps = []; 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 = newMessageEvent($clonedMessage, $clonedEnvelope, (string)$this->transport, true); $this->dispatcher->dispatch($event); $stamps = $event->getStamps();
if($message instanceof TemplatedEmail && !$message->isRendered()){ thrownewLogicException(sprintf('You must configure a "%s" when a "%s" instance has a text or HTML template set.', BodyRendererInterface::class, get_debug_type($message))); }