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

Public Member Functions

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

Protected Member Functions

TransportFactory getTransportFactory ()
 

Protected Attributes

TransportInterface $transport
 
array $mailSettings = array( )
 
SentMessage null $sentMessage
 
string $mailerHeader = 'TYPO3'
 
EventDispatcherInterface $eventDispatcher
 

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 37 of file Mailer.php.

Constructor & Destructor Documentation

◆ __construct()

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

When constructing, also initializes the Symfony Transport like configured

Parameters
TransportInterface | null$transport‪optionally pass a transport to the constructor.
EventDispatcherInterface | null$eventDispatcher
Exceptions
CoreException

Definition at line 66 of file Mailer.php.

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

Member Function Documentation

◆ getRealTransport()

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

Returns the real transport (not a spool).

Returns
‪TransportInterface

Definition at line 177 of file Mailer.php.

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

◆ getSentMessage()

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

Definition at line 126 of file Mailer.php.

References TYPO3\CMS\Core\Mail\Mailer\$sentMessage.

◆ getTransport()

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

Definition at line 131 of file Mailer.php.

References TYPO3\CMS\Core\Mail\Mailer\$transport.

◆ getTransportFactory()

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

◆ initializeTransport()

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

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'

Exceptions
CoreException

Definition at line 152 of file Mailer.php.

References TYPO3\CMS\Core\Mail\TransportFactory\get(), and 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

Parameters
array | null$mailSettings

Definition at line 163 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

◆ $eventDispatcher

EventDispatcherInterface TYPO3\CMS\Core\Mail\Mailer::$eventDispatcher
protected

Definition at line 57 of file Mailer.php.

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

◆ $mailerHeader

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

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

Definition at line 53 of file Mailer.php.

◆ $mailSettings

array TYPO3\CMS\Core\Mail\Mailer::$mailSettings = array( )
protected

◆ $sentMessage

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

Definition at line 49 of file Mailer.php.

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

◆ $transport

TransportInterface TYPO3\CMS\Core\Mail\Mailer::$transport
protected