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

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

Mailer $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 (   $addresses)

◆ addCc()

TYPO3\CMS\Core\Mail\MailMessage::addCc (   $addresses)

◆ addFrom()

TYPO3\CMS\Core\Mail\MailMessage::addFrom (   $addresses)

◆ addReplyTo()

TYPO3\CMS\Core\Mail\MailMessage::addReplyTo (   $addresses)

◆ addTo()

TYPO3\CMS\Core\Mail\MailMessage::addTo (   $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 262 of file MailMessage.php.

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

◆ convertNamedAddress()

◆ initializeMailer()

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

Definition at line 39 of file MailMessage.php.

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

◆ isSent()

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

Checks whether the message has been sent.

Returns
‪bool

Definition at line 69 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 52 of file MailMessage.php.

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

◆ setBcc()

MailMessage 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
Returns
MailMessage

Definition at line 221 of file MailMessage.php.

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

◆ setCc()

MailMessage 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
Returns
MailMessage

Definition at line 201 of file MailMessage.php.

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

◆ setDate()

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

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

Parameters
int$date
Returns
MailMessage

Definition at line 99 of file MailMessage.php.

◆ setFrom()

MailMessage 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
Returns
MailMessage

Definition at line 142 of file MailMessage.php.

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

◆ setReadReceiptTo()

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

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

Parameters
string$address
Returns
MailMessage

Definition at line 233 of file MailMessage.php.

◆ setReplyTo()

MailMessage 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
Returns
MailMessage

Definition at line 161 of file MailMessage.php.

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

◆ setReturnPath()

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

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

Parameters
string$address
Returns
MailMessage

Definition at line 110 of file MailMessage.php.

◆ setSender()

MailMessage 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
Returns
MailMessage

Definition at line 124 of file MailMessage.php.

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

◆ setSubject()

MailMessage 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
Returns
MailMessage

Definition at line 88 of file MailMessage.php.

◆ setTo()

MailMessage 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
Returns
MailMessage

Definition at line 181 of file MailMessage.php.

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

Member Data Documentation

◆ $mailer

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

Definition at line 31 of file MailMessage.php.

◆ $sent

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

TRUE if the message has been sent.

Definition at line 37 of file MailMessage.php.

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