Feature: #97747 - Introduce MailerInterface
See forge#97747
Description
To be able to use your own custom mailer implementation in the TYPO3 Core, an
interface \TYPO3\
is introduced, which extends
\Symfony\
By default, \TYPO3\
is registered as implementation in
Configuration/
.
Example
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);
Impact
This change makes it possible to create your own \My\
that implements
\TYPO3\
which is used by TYPO3 core. Therefore, it is recommended
to use the interface \TYPO3\
, to let dependency injection inject the
desired implementation for every \TYPO3\
.
Add the following line in Configuration/
, to ensure that your custom
implementation can be injected.
TYPO3\CMS\Core\Mail\MailerInterface:
alias: My\Custom\Mailer