Skip to content

Commit 11596b0

Browse files
committed
Document MessageEvent::reject()
1 parent 7a79bc7 commit 11596b0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mailer.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,20 @@ the email is sent::
14831483
// do something with the message
14841484
}
14851485

1486+
If you want to stop the Message from being sent, call ``reject()`` (it will
1487+
also stop the event propagation)::
1488+
1489+
use Symfony\Component\Mailer\Event\MessageEvent;
1490+
1491+
public function onMessage(MessageEvent $event): void
1492+
{
1493+
$event->reject();
1494+
}
1495+
1496+
.. versionadded:: 6.3
1497+
1498+
The ``reject()`` method was introduced in Symfony 6.3.
1499+
14861500
.. tip::
14871501

14881502
When using a ``MessageEvent`` listener to

0 commit comments

Comments
 (0)