File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -1021,6 +1021,43 @@ you have a transport called ``async``, you can route the message there:
1021
1021
Thanks to this, instead of being delivered immediately, messages will be sent to
1022
1022
the transport to be handled later (see :ref: `messenger-worker `).
1023
1023
1024
+ Events
1025
+ ------
1026
+
1027
+ The mailer component also throws a events:
1028
+
1029
+ MessageEvent
1030
+ ~~~~~~~~~~~~
1031
+
1032
+ The MessageEvent allows you to manipulate the send message:
1033
+
1034
+ .. code-block :: php
1035
+
1036
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1037
+ use Symfony\Component\Mailer\Event\MessageEvent;
1038
+ use Symfony\Component\Mime\Email;
1039
+
1040
+ class MailerListener implements EventSubscriberInterface
1041
+ {
1042
+ public static function getSubscribedEvents()
1043
+ {
1044
+ return [
1045
+ MessageEvent::class => 'onMessage',
1046
+ ];
1047
+ }
1048
+
1049
+ public function onMessage(MessageEvent $event): void
1050
+ {
1051
+ $message = $event->getMessage();
1052
+ if (!$message instanceof Email) {
1053
+ return;
1054
+ }
1055
+
1056
+ // do something with the message
1057
+ }
1058
+ }
1059
+
1060
+
1024
1061
Development & Debugging
1025
1062
-----------------------
1026
1063
You can’t perform that action at this time.
0 commit comments