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

Public Member Functions

bool send ()
 
 isSent ()
 
 setSubject ($subject)
 
 setDate ($date)
 
 setReturnPath ($address)
 
 setSender ($address, $name=null)
 
 setFrom ($addresses, $name=null)
 
 setReplyTo ($addresses, $name=null)
 
 setTo ($addresses, $name=null)
 
 setCc ($addresses, $name=null)
 
 setBcc ($addresses, $name=null)
 
 setReadReceiptTo (string $address)
 
 addFrom (Address|string|null|array ... $addresses)
 
 addReplyTo (Address|string|null|array ... $addresses)
 
 addTo (Address|string|null|array ... $addresses)
 
 addCc (Address|string|null|array ... $addresses)
 
 addBcc (Address|string|null|array ... $addresses)
 

Protected Member Functions

Address[] convertNamedAddress (... $args)
 
Address[] convertAddresses ($addresses)
 
 checkArguments ($addresses, string $name=null)
 

Protected Attributes

MailerInterface $mailer
 
bool $sent = false
 

Private Member Functions

 initializeMailer ()
 

Detailed Description

Adapter for Symfony Mime to be used by TYPO3 extensions, also provides some backwards-compatibility for previous TYPO3 installations where send() was baked into the MailMessage object.

Definition at line 27 of file MailMessage.php.

Member Function Documentation

◆ addBcc()

TYPO3\CMS\Core\Mail\MailMessage::addBcc ( Address|string|null|array ...  $addresses)

◆ addCc()

TYPO3\CMS\Core\Mail\MailMessage::addCc ( Address|string|null|array ...  $addresses)

◆ addFrom()

TYPO3\CMS\Core\Mail\MailMessage::addFrom ( Address|string|null|array ...  $addresses)

◆ addReplyTo()

TYPO3\CMS\Core\Mail\MailMessage::addReplyTo ( Address|string|null|array ...  $addresses)

◆ addTo()

TYPO3\CMS\Core\Mail\MailMessage::addTo ( Address|string|null|array ...  $addresses)

◆ checkArguments()

TYPO3\CMS\Core\Mail\MailMessage::checkArguments (   $addresses,
string  $name = null 
)
protected

◆ convertAddresses()

Address [] TYPO3\CMS\Core\Mail\MailMessage::convertAddresses (   $addresses)
protected

Converts Addresses into Address/NamedAddress objects.

Parameters
string | array$addresses
Returns
‪Address[]

Definition at line 245 of file MailMessage.php.

Referenced by TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

◆ convertNamedAddress()

◆ initializeMailer()

TYPO3\CMS\Core\Mail\MailMessage::initializeMailer ( )
private

Definition at line 36 of file MailMessage.php.

Referenced by TYPO3\CMS\Core\Mail\MailMessage\send().

◆ isSent()

TYPO3\CMS\Core\Mail\MailMessage::isSent ( )

Checks whether the message has been sent.

Definition at line 65 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\$sent.

◆ send()

bool TYPO3\CMS\Core\Mail\MailMessage::send ( )

Sends the message.

This is a short-hand method. It is however more useful to create a Mailer instance which can be used via Mailer->send($message);

Returns
‪bool whether the message was accepted or not

Definition at line 50 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\$sent, and TYPO3\CMS\Core\Mail\MailMessage\initializeMailer().

◆ setBcc()

TYPO3\CMS\Core\Mail\MailMessage::setBcc (   $addresses,
  $name = null 
)

Set the Bcc addresses of this message.

If multiple recipients will receive the message an array should be used. Example: array('recei.nosp@m.ver@.nosp@m.domai.nosp@m.n.or.nosp@m.g', 'other.nosp@m.@dom.nosp@m.ain.o.nosp@m.rg' => 'A name')

If $name is passed and the first parameter is a string, this name will be associated with the address. If $name is passed and the first parameter is not a string, an exception is thrown.

Parameters
string | array$addresses
string$name‪optional

Definition at line 207 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\checkArguments(), and TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

◆ setCc()

TYPO3\CMS\Core\Mail\MailMessage::setCc (   $addresses,
  $name = null 
)

Set the Cc addresses of this message.

If multiple recipients will receive the message an array should be used. Example: array('recei.nosp@m.ver@.nosp@m.domai.nosp@m.n.or.nosp@m.g', 'other.nosp@m.@dom.nosp@m.ain.o.nosp@m.rg' => 'A name')

If $name is passed and the first parameter is a string, this name will be associated with the address. If $name is passed and the first parameter is not a string, an exception is thrown.

Parameters
string | array$addresses
string$name‪optional

Definition at line 188 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\checkArguments(), and TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

◆ setDate()

TYPO3\CMS\Core\Mail\MailMessage::setDate (   $date)

Set the origination date of the message as a UNIX timestamp.

Parameters
int$date

Definition at line 92 of file MailMessage.php.

◆ setFrom()

TYPO3\CMS\Core\Mail\MailMessage::setFrom (   $addresses,
  $name = null 
)

Set the from address of this message.

You may pass an array of addresses if this message is from multiple people.

If $name is passed and the first parameter is a string, this name will be associated with the address. If $name is passed and the first parameter is not a string, an exception is thrown.

Parameters
string | array$addresses
string$name‪optional

Definition at line 132 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\checkArguments(), and TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

◆ setReadReceiptTo()

TYPO3\CMS\Core\Mail\MailMessage::setReadReceiptTo ( string  $address)

Ask for a delivery receipt from the recipient to be sent to $addresses.

Definition at line 216 of file MailMessage.php.

◆ setReplyTo()

TYPO3\CMS\Core\Mail\MailMessage::setReplyTo (   $addresses,
  $name = null 
)

Set the reply-to address of this message.

You may pass an array of addresses if replies will go to multiple people.

If $name is passed and the first parameter is a string, this name will be associated with the address. If $name is passed and the first parameter is not a string, an exception is thrown.

Parameters
string | array$addresses
string$name‪optional

Definition at line 150 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\checkArguments(), and TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

◆ setReturnPath()

TYPO3\CMS\Core\Mail\MailMessage::setReturnPath (   $address)

Set the return-path (the bounce address) of this message.

Parameters
string$address

Definition at line 102 of file MailMessage.php.

◆ setSender()

TYPO3\CMS\Core\Mail\MailMessage::setSender (   $address,
  $name = null 
)

Set the sender of this message.

This does not override the From field, but it has a higher significance.

Parameters
string$address
string$name‪optional

Definition at line 115 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

◆ setSubject()

TYPO3\CMS\Core\Mail\MailMessage::setSubject (   $subject)

compatibility methods to allow for associative arrays as [name => email address] as it was possible in TYPO3 v9 / SwiftMailer.

Also, ensure to switch to Address objects and the ->subject()/->from() methods directly to directly use the new API. Set the subject of the message.

Parameters
string$subject

Definition at line 82 of file MailMessage.php.

◆ setTo()

TYPO3\CMS\Core\Mail\MailMessage::setTo (   $addresses,
  $name = null 
)

Set the to addresses of this message.

If multiple recipients will receive the message an array should be used. Example: array('recei.nosp@m.ver@.nosp@m.domai.nosp@m.n.or.nosp@m.g', 'other.nosp@m.@dom.nosp@m.ain.o.nosp@m.rg' => 'A name')

If $name is passed and the first parameter is a string, this name will be associated with the address. If $name is passed and the first parameter is not a string, an exception is thrown.

Parameters
string | array$addresses
string$name‪optional

Definition at line 169 of file MailMessage.php.

References TYPO3\CMS\Core\Mail\MailMessage\checkArguments(), and TYPO3\CMS\Core\Mail\MailMessage\convertNamedAddress().

Member Data Documentation

◆ $mailer

MailerInterface TYPO3\CMS\Core\Mail\MailMessage::$mailer
protected

Definition at line 29 of file MailMessage.php.

◆ $sent

bool TYPO3\CMS\Core\Mail\MailMessage::$sent = false
protected

TRUE if the message has been sent.

Definition at line 34 of file MailMessage.php.

Referenced by TYPO3\CMS\Core\Mail\MailMessage\isSent(), and TYPO3\CMS\Core\Mail\MailMessage\send().