File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1404,6 +1404,39 @@ Here's an example of making one available to download::
14041404 As it's possible for :class: `Symfony\\ Component\\ Mime\\ DraftEmail `'s to be created
14051405 without a To/From they cannot be sent with the mailer.
14061406
1407+ Mailer Events
1408+ -------------
1409+
1410+ MessageEvent
1411+ ~~~~~~~~~~~~
1412+
1413+ ``MessageEvent `` allows to change the Message and the Envelope before the email
1414+ is sent::
1415+
1416+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1417+ use Symfony\Component\Mailer\Event\MessageEvent;
1418+ use Symfony\Component\Mime\Email;
1419+
1420+ class MailerSubscriber implements EventSubscriberInterface
1421+ {
1422+ public static function getSubscribedEvents()
1423+ {
1424+ return [
1425+ MessageEvent::class => 'onMessage',
1426+ ];
1427+ }
1428+
1429+ public function onMessage(MessageEvent $event): void
1430+ {
1431+ $message = $event->getMessage();
1432+ if (!$message instanceof Email) {
1433+ return;
1434+ }
1435+
1436+ // do something with the message
1437+ }
1438+ }
1439+
14071440Development & Debugging
14081441-----------------------
14091442
You can’t perform that action at this time.
0 commit comments