AfterMailerInitializationEvent¶
The PSR-14 event \TYPO3\
is fired once a new mailer is instantiated with specific transport
settings. So it is possible to add custom mailing settings.
Example¶
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Mail\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/after-mailer-initialization'
Read how to configure dependency injection in extensions.
An example listener, which hooks into the Mailer API to modify mailer settings to not send any emails ("null mailer"), could look like this:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Mail\EventListener;
use TYPO3\CMS\Core\Mail\Event\AfterMailerInitializationEvent;
final class MyEventListener
{
public function __invoke(AfterMailerInitializationEvent $event): void
{
$event->getMailer()->injectMailSettings(['transport' => 'null']);
}
}
API¶
- class AfterMailerInitializationEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Core\ Mail\ Event\ After Mailer Initialization Event
This event is fired once a new Mailer is instantiated with specific transport settings.
So it is possible to add custom mailing settings.
- getMailer ( ) ¶
-
- Returns
-
\Symfony\
Component\ Mailer\ Mailer Interface