‪TYPO3CMS  11.5
TYPO3\CMS\Core\Mail\MemorySpool Class Reference
Inheritance diagram for TYPO3\CMS\Core\Mail\MemorySpool:
TYPO3\CMS\Core\SingletonInterface TYPO3\CMS\Core\Mail\DelayedTransportInterface TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures\FakeMemorySpoolFixture

Public Member Functions

 __construct (EventDispatcherInterface $dispatcher=null, LoggerInterface $logger=null)
 
 __destruct ()
 
 flushQueue (TransportInterface $transport)
 
 __toString ()
 

Protected Member Functions

 doSend (SentMessage $message)
 

Protected Attributes

LoggerInterface null $logger
 
SentMessage[] $queuedMessages = array( )
 
int $retries = 3
 

Detailed Description

Because TYPO3 doesn't offer a terminate signal or hook, and taking in account the risk that extensions do some redirects or even exit, we simply use the destructor of a singleton class which should be pretty much at the end of a request.

To have only one memory spool per request seems to be more appropriate anyway.

This class is experimental and subject to change!

Definition at line 40 of file MemorySpool.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Mail\MemorySpool::__construct ( EventDispatcherInterface  $dispatcher = null,
LoggerInterface  $logger = null 
)

Create a new MemorySpool

Parameters
EventDispatcherInterface$dispatcher
LoggerInterface$logger

Definition at line 66 of file MemorySpool.php.

References TYPO3\CMS\Core\Mail\MemorySpool\$logger.

◆ __destruct()

TYPO3\CMS\Core\Mail\MemorySpool::__destruct ( )

Sends out the messages in the memory

Reimplemented in TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures\FakeMemorySpoolFixture.

Definition at line 80 of file MemorySpool.php.

References TYPO3\CMS\Core\Mail\MemorySpool\flushQueue().

Member Function Documentation

◆ __toString()

TYPO3\CMS\Core\Mail\MemorySpool::__toString ( )

Definition at line 136 of file MemorySpool.php.

◆ doSend()

TYPO3\CMS\Core\Mail\MemorySpool::doSend ( SentMessage  $message)
protected

Stores a message in the queue.

Parameters
SentMessage$message

Definition at line 131 of file MemorySpool.php.

◆ flushQueue()

TYPO3\CMS\Core\Mail\MemorySpool::flushQueue ( TransportInterface  $transport)

‪Sends messages using the given transport instance

Parameters
TransportInterface$transport
Returns
‪int the number of messages sent

Implements TYPO3\CMS\Core\Mail\DelayedTransportInterface.

Definition at line 95 of file MemorySpool.php.

References TYPO3\CMS\Core\Mail\MemorySpool\$retries.

Referenced by TYPO3\CMS\Core\Mail\MemorySpool\__destruct().

Member Data Documentation

◆ $logger

LoggerInterface null TYPO3\CMS\Core\Mail\MemorySpool::$logger
protected

The logger instance.

Definition at line 48 of file MemorySpool.php.

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

◆ $queuedMessages

SentMessage [] TYPO3\CMS\Core\Mail\MemorySpool::$queuedMessages = array( )
protected

Definition at line 52 of file MemorySpool.php.

◆ $retries

int TYPO3\CMS\Core\Mail\MemorySpool::$retries = 3
protected

Maximum number of retries when the real transport has failed.

Definition at line 58 of file MemorySpool.php.

Referenced by TYPO3\CMS\Core\Mail\MemorySpool\flushQueue().