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 @@ -1021,6 +1021,39 @@ 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
+ MessageEvent
1028
+ ~~~~~~~~~~~~
1029
+
1030
+ The MessageEvent allows the transformation of a Message and the Envelope before the email is sent::
1031
+
1032
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1033
+ use Symfony\Component\Mailer\Event\MessageEvent;
1034
+ use Symfony\Component\Mime\Email;
1035
+
1036
+ class MailerSubscriber implements EventSubscriberInterface
1037
+ {
1038
+ public static function getSubscribedEvents()
1039
+ {
1040
+ return [
1041
+ MessageEvent::class => 'onMessage',
1042
+ ];
1043
+ }
1044
+
1045
+ public function onMessage(MessageEvent $event): void
1046
+ {
1047
+ $message = $event->getMessage();
1048
+ if (!$message instanceof Email) {
1049
+ return;
1050
+ }
1051
+
1052
+ // do something with the message
1053
+ }
1054
+ }
1055
+
1056
+
1024
1057
Development & Debugging
1025
1058
-----------------------
1026
1059
You can’t perform that action at this time.
0 commit comments