@@ -1204,9 +1204,40 @@ you have a transport called ``async``, you can route the message there:
12041204 ->senders(['async']);
12051205 };
12061206
1207+ Thanks to this, instead of being delivered immediately, messages will be sent
1208+ to the transport to be handled later (see:ref: `messenger-worker `). Note that
1209+ the "rendering" of the email (computed headers, body rendering, ...) is also
1210+ deferred and will only happen just before the email is sent by the Messenger
1211+ handler.
12071212
1208- Thanks to this, instead of being delivered immediately, messages will be sent to
1209- the transport to be handled later (see:ref: `messenger-worker `).
1213+ ..versionadded ::6.2
1214+
1215+ The following example about rendering the email before calling
1216+ ``$mailer->send($email) `` works as of Symfony 6.2.
1217+
1218+ When sending an email asynchronously, its instance must be serializable.
1219+ This is always the case for:class: `Symfony\\ Bridge\\ Twig\\ Mime\\ Email `
1220+ instances, but when sending a
1221+ :class: `Symfony\\ Bridge\\ Twig\\ Mime\\ TemplatedEmail `, you must ensure that
1222+ the ``context `` is serializable. If you have non-serializable variables,
1223+ like Doctrine entities, either replace them with more specific variables or
1224+ render the email before calling ``$mailer->send($email) ``:
1225+
1226+ ..code-block ::php
1227+
1228+ use Symfony\Component\Mailer\MailerInterface;
1229+ use Symfony\Component\Mime\BodyRendererInterface;
1230+
1231+ public function action(MailerInterface $mailer, BodyRendererInterface $bodyRenderer)
1232+ {
1233+ $email = (new TemplatedEmail())
1234+ ->htmlTemplate($template)
1235+ ->context($context)
1236+ ;
1237+ $bodyRenderer->render($email);
1238+
1239+ $mailer->send($email);
1240+ }
12101241
12111242 You can configure which bus is used to dispatch the message using the ``message_bus `` option.
12121243You can also set this to ``false `` to call the Mailer transport directly and