Skip to content

Message ​

Type
Class
Namespace
craft\mail
Inherits
craft\mail\Message » yii\symfonymailer\Message
Since
3.0.0

Represents an email message.

View source

Public Properties ​

PropertyDescription
error\Symfony\Component\Mailer\Exception\TransportExceptionInterface, null – The caught error object, if the message failed to send
keystring, null – The key of the message that should be loaded
languagestring, null – The language that the email should be sent in, based on the first craft\elements\User model passed into setTo() with a preferred language
variablesarray, null – Any variables that should be applied to the template when it is rendered

error ​

Type
\Symfony\Component\Mailer\Exception\TransportExceptionInterface, null
Default value
null

The caught error object, if the message failed to send

View source

key ​

Type
string, null
Default value
null

The key of the message that should be loaded

View source

language ​

Type
string, null
Default value
null

The language that the email should be sent in, based on the first craft\elements\User model passed into setTo() with a preferred language

View source

variables ​

Type
array, null
Default value
null

Any variables that should be applied to the template when it is rendered

View source

Public Methods ​

MethodDescription
setBcc()Sets the BCC (hidden copy receiver) addresses of this message.
setCc()Sets the CC (additional copy receiver) addresses of this message.
setFrom()Sets the message sender.
setReplyTo()Sets the Reply-To email.
setTo()Sets the message recipient(s).

setBcc() ​

Sets the BCC (hidden copy receiver) addresses of this message.

View source

Arguments ​

  • $bcc (string, (\craft\elements\User|string)[], craft\elements\User, null) – The hidden copied receiver’s email address, or their user model(s). You may pass an array of addresses if multiple recipients should receive this message. You may also specify receiver name in addition to email address using format: [email => name].

Returns ​

self – Self reference

setCc() ​

Sets the CC (additional copy receiver) addresses of this message.

View source

Arguments ​

  • $cc (string, (\craft\elements\User|string)[], craft\elements\User) – The copied receiver’s email address, or their user model(s). You may pass an array of addresses if multiple recipients should receive this message. You may also specify receiver name in addition to email address using format: [email => name].

Returns ​

self – Self reference

setFrom() ​

Sets the message sender.

View source

Arguments ​

  • $from (string, (\craft\elements\User|string)[], craft\elements\User) – The sender’s email address, or their user model(s). You may pass an array of addresses if this message is from multiple people. You may also specify sender name in addition to email address using format: [email => name].

Returns ​

self – Self reference

setReplyTo() ​

Since
3.4.0

Sets the Reply-To email.

View source

Arguments ​

  • $replyTo (string, (\craft\elements\User|string)[], craft\elements\User) – The Reply-To email address, or their user model(s). You may pass an array of addresses if this message is from multiple people. You may also specify Reply-To name in addition to email address using format: [email => name].

Returns ​

self – Self reference

setTo() ​

Sets the message recipient(s).

View source

Arguments ​

  • $to (string, (\craft\elements\User|string)[], craft\elements\User) – The receiver’s email address, or their user model(s). You may pass an array of addresses if multiple recipients should receive this message. You may also specify receiver name in addition to email address using format: [email => name].

Returns ​

self – Self reference