‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Mail\Mailer Class Reference
Inheritance diagram for TYPO3\CMS\Core\Mail\Mailer:

Public Member Functions

 __construct (protected ?TransportInterface $transport=null, protected readonly ?EventDispatcherInterface $eventDispatcher=null,)
 send (RawMessage $message, ?Envelope $envelope=null)
 getSentMessage ()
 getTransport ()
 injectMailSettings (?array $mailSettings=null)
 getRealTransport ()

Protected Member Functions

 getTransportFactory ()

Protected Attributes

array $mailSettings = []
SentMessage $sentMessage
string $mailerHeader = 'TYPO3'

Private Member Functions

 initializeTransport ()

Detailed Description

Adapter for Symfony/Mailer to be used by TYPO3 extensions.

This will use the setting in TYPO3_CONF_VARS to choose the correct transport for it to work out-of-the-box.

Definition at line 40 of file Mailer.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Mail\Mailer::__construct ( protected ?TransportInterface  $transport = null,
protected readonly ?EventDispatcherInterface  $eventDispatcher = null 

When constructing, also initializes the Symfony Transport like configured

TransportInterface | null$transport‪optionally pass a transport to the constructor.

Definition at line 57 of file Mailer.php.

References TYPO3\CMS\Core\Mail\Mailer\initializeTransport(), and TYPO3\CMS\Core\Mail\Mailer\injectMailSettings().

Member Function Documentation

◆ getRealTransport()

TYPO3\CMS\Core\Mail\Mailer::getRealTransport ( )

Returns the real transport (not a spool).

Implements TYPO3\CMS\Core\Mail\MailerInterface.

Definition at line 163 of file Mailer.php.

References $GLOBALS, TYPO3\CMS\Core\Mail\Mailer\$mailSettings, and TYPO3\CMS\Core\Mail\Mailer\getTransportFactory().

◆ getSentMessage()

TYPO3\CMS\Core\Mail\Mailer::getSentMessage ( )

◆ getTransport()

TYPO3\CMS\Core\Mail\Mailer::getTransport ( )

Implements TYPO3\CMS\Core\Mail\MailerInterface.

Definition at line 124 of file Mailer.php.

◆ getTransportFactory()

TYPO3\CMS\Core\Mail\Mailer::getTransportFactory ( )

◆ initializeTransport()

TYPO3\CMS\Core\Mail\Mailer::initializeTransport ( )

Prepares a transport using the TYPO3_CONF_VARS configuration

Used options: $TYPO3_CONF_VARS['MAIL']['transport'] = 'smtp' | 'sendmail' | 'null' | 'mbox'

$TYPO3_CONF_VARS['MAIL']['transport_smtp_server'] = 'smtp.example.org:25'; $TYPO3_CONF_VARS['MAIL']['transport_smtp_encrypt'] = FALSE; # requires openssl in PHP $TYPO3_CONF_VARS['MAIL']['transport_smtp_username'] = 'username'; $TYPO3_CONF_VARS['MAIL']['transport_smtp_password'] = 'password';

$TYPO3_CONF_VARS['MAIL']['transport_sendmail_command'] = '/usr/sbin/sendmail -bs'


Definition at line 145 of file Mailer.php.

References TYPO3\CMS\Core\Mail\Mailer\getTransportFactory().

Referenced by TYPO3\CMS\Core\Mail\Mailer\__construct().

◆ injectMailSettings()

TYPO3\CMS\Core\Mail\Mailer::injectMailSettings ( ?array  $mailSettings = null)

This method is only used in unit tests

Definition at line 155 of file Mailer.php.

References $GLOBALS, and TYPO3\CMS\Core\Mail\Mailer\$mailSettings.

Referenced by TYPO3\CMS\Core\Mail\Mailer\__construct().

◆ send()

TYPO3\CMS\Core\Mail\Mailer::send ( RawMessage  $message,
?Envelope  $envelope = null 

Member Data Documentation

◆ $mailerHeader

string TYPO3\CMS\Core\Mail\Mailer::$mailerHeader = 'TYPO3'

This will be added as X-Mailer to all outgoing mails

Definition at line 49 of file Mailer.php.

◆ $mailSettings

array TYPO3\CMS\Core\Mail\Mailer::$mailSettings = []

◆ $sentMessage

SentMessage TYPO3\CMS\Core\Mail\Mailer::$sentMessage

Definition at line 44 of file Mailer.php.

Referenced by TYPO3\CMS\Core\Mail\Mailer\getSentMessage().