New in version 12.0.

The PSR-14 event \TYPO3\CMS\Core\Mail\Event\AfterMailerSentMessageEvent is dispatched as soon as the message has been sent via the corresponding \Symfony\Component\Mailer\Transport\TransportInterface. It receives the current mailer instance, which depends on the implementation - usually \TYPO3\CMS\Core\Mail\Mailer. It contains the \Symfony\Component\Mailer\SentMessage object, which can be retrieved using the getSentMessage() method.




namespace MyVendor\MyExtension\Mail\EventListener;

use Psr\Log\LoggerInterface;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Mail\Event\AfterMailerSentMessageEvent;
use TYPO3\CMS\Core\Mail\Mailer;

    identifier: 'my-extension/process-sent-message'
final class MyEventListener
    public function __construct(
        private readonly LoggerInterface $logger
    ) {}

    public function __invoke(AfterMailerSentMessageEvent $event): void
        $mailer = $event->getMailer();
        if (!$mailer instanceof Mailer) {

        $sentMessage = $mailer->getSentMessage();
        if ($sentMessage !== null) {

New in version 13.0: The PHP attribute \TYPO3\CMS\Core\Attribute\AsEventListener has been introduced to tag a PHP class as an event listener. Alternatively, or if you need to be compatible with older TYPO3 versions, you can also register an event listener via the Configuration/Services.yaml file. Switch to an older version of this page for an example or have a look at the section Implementing an event listener in your extension.


class TYPO3\CMS\Core\Mail\Event\AfterMailerSentMessageEvent

This event is fired once a Mailer has sent a message and allows listeners to execute further code afterwards, depending on the result, e.g. the SentMessage.

Note: Usually TYPO3CMSCoreMailMailer is given to the event. This implementation allows to retrieve the SentMessage using the getSentMessage() method. Depending on the Transport, used to send the message, this might also be NULL.

Return type