Feature: #97747 - Introduce MailerInterface

See forge#97747


To be able to use your own custom mailer implementation in the TYPO3 Core, an interface \TYPO3\CMS\Core\Mail\MailerInterface is introduced, which extends \Symfony\Component\Mailer\MailerInterface

By default, \TYPO3\CMS\Core\Mail\Mailer is registered as implementation in Configuration/Services.yaml.


use TYPO3\CMS\Core\Mail\MailerInterface;

class MyClass
    public function __construct(
        private readonly MailerInterface $mailer
    ) {

Or where constructor injection is not possible:

$mailer = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Mail\MailerInterface::class);


This change makes it possible to create your own \My\Custom\Mailer that implements \TYPO3\CMS\Core\Mail\MailerInterface which is used by TYPO3 core. Therefore, it is recommended to use the interface \TYPO3\CMS\Core\Mail\MailerInterface, to let dependency injection inject the desired implementation for every \TYPO3\CMS\Core\Mail\MailerInterface.

Add the following line in Configuration/Services.yaml, to ensure that your custom implementation can be injected.

  alias: My\Custom\Mailer