File tree 1 file changed +34
-1
lines changed
1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -605,7 +605,7 @@ and headers.
605
605
.. versionadded :: 5.2
606
606
607
607
The ``headers `` option was introduced in Symfony 5.2.
608
-
608
+
609
609
.. caution ::
610
610
611
611
Some third-party providers don't support the usage of keywords like ``from ``
@@ -1356,6 +1356,39 @@ The following transports only support tags:
1356
1356
1357
1357
* OhMySMTP
1358
1358
1359
+ Mailer Events
1360
+ -------------
1361
+
1362
+ MessageEvent
1363
+ ~~~~~~~~~~~~
1364
+
1365
+ ``MessageEvent `` allows to change the Message and the Envelope before the email
1366
+ is sent::
1367
+
1368
+ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1369
+ use Symfony\Component\Mailer\Event\MessageEvent;
1370
+ use Symfony\Component\Mime\Email;
1371
+
1372
+ class MailerSubscriber implements EventSubscriberInterface
1373
+ {
1374
+ public static function getSubscribedEvents()
1375
+ {
1376
+ return [
1377
+ MessageEvent::class => 'onMessage',
1378
+ ];
1379
+ }
1380
+
1381
+ public function onMessage(MessageEvent $event): void
1382
+ {
1383
+ $message = $event->getMessage();
1384
+ if (!$message instanceof Email) {
1385
+ return;
1386
+ }
1387
+
1388
+ // do something with the message
1389
+ }
1390
+ }
1391
+
1359
1392
Development & Debugging
1360
1393
-----------------------
1361
1394
You can’t perform that action at this time.
0 commit comments