Message

Type
Class
Namespace
craft\mail
Inherits
craft\mail\Message » yii\swiftmailer\Message » yii\mail\BaseMessage » yii\base\BaseObject
Implements
yii\base\Configurable, yii\mail\MessageInterface
Since
3.0.0

Represents an email message.

View source

# Public Properties

Property Description
bcc string, array – The Bcc (hidden copy receiver) addresses of this message.
cc string, array – The Cc (additional copy receiver) addresses of this message.
charset string – The character set of this message.
from string, array – The sender
headers array – Headers in format: [name => value].
htmlBody string – Message HTML content.
key string, null – The key of the message that should be loaded
language string, 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
mailer yii\mail\MailerInterface – The mailer instance that created this message.
priority integer – Priority value as integer in range: `1.
readReceiptTo string – Receipt receive email addresses.
replyTo string, array – The reply-to address of this message.
returnPath string – The bounce email address.
signature array, callable, \Swift_Signer – Signature specification.
subject string – The message subject
swiftMessage \Swift_Message – Swift message instance.
textBody string – Message plain text content.
to string, array – The message recipients
variables array, null – Any variables that should be applied to the template when it is rendered

# key

Type
string, null

The key of the message that should be loaded

View source

# language

Type
string, 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

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

View source

# Public Methods

Method Description
__call() Calls the named method which is not a class method.
__clone() This method is called after the object is created by cloning an existing one.
__construct() Constructor.
__get() Returns the value of an object property.
__isset() Checks if a property is set, i.e. defined and not null.
__set() Sets value of an object property.
__toString() PHP magic method that returns the string representation of this object.
__unset() Sets an object property to null.
addHeader() Adds custom header value to the message.
addSignature() Adds message signature.
attach() Attaches existing file to the email message.
attachContent() Attach specified content as file for the email message.
canGetProperty() Returns a value indicating whether a property can be read.
canSetProperty() Returns a value indicating whether a property can be set.
className() Returns the fully qualified name of this class.
embed() Attach a file and return it's CID source.
embedContent() Attach a content as file and return it's CID source.
getBcc() Returns the Bcc (hidden copy receiver) addresses of this message.
getCc() Returns the Cc (additional copy receiver) addresses of this message.
getCharset() Returns the character set of this message.
getFrom() Returns the message sender.
getHeader() Returns all values for the specified header.
getPriority() Returns the priority of this message.
getReadReceiptTo() Get the addresses to which a read-receipt will be sent.
getReplyTo() Returns the reply-to address of this message.
getReturnPath() Returns the return-path (the bounce address) of this message.
getSubject() Returns the message subject.
getSwiftMessage()
getTo() Returns the message recipient(s).
hasMethod() Returns a value indicating whether a method is defined.
hasProperty() Returns a value indicating whether a property is defined.
init() Initializes the object.
send() Sends this email message.
setBcc() Sets the BCC (hidden copy receiver) addresses of this message.
setCc() Sets the CC (additional copy receiver) addresses of this message.
setCharset() Sets the character set of this message.
setFrom() Sets the message sender.
setHeader() Sets custom header value to the message.
setHeaders() Sets custom header values to the message.
setHtmlBody() Sets message HTML content.
setPriority() Set the priority of this message.
setReadReceiptTo() Sets the ask for a delivery receipt from the recipient to be sent to $addresses.
setReplyTo() Sets the Reply-To email.
setReturnPath() Set the return-path (the bounce address) of this message.
setSignature() Sets message signature
setSubject() Sets the message subject.
setTextBody() Sets message plain text content.
setTo() Sets the message recipient(s).
toString() Returns string representation of this message.

# setBcc()

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

View source

Arguments

  • $bcc (string, array, craft\elements\User, craft\elements\User[]) – 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

static – Self reference

# setCc()

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

View source

Arguments

  • $cc (string, array, craft\elements\User, 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

static – Self reference

# setFrom()

Sets the message sender.

View source

Arguments

  • $from (string, array, craft\elements\User, 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

static – Self reference

# setReplyTo()

Since
3.4.0

Sets the Reply-To email.

View source

Arguments

  • $replyTo (string, array, craft\elements\User, 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

static – Self reference

# setTo()

Sets the message recipient(s).

View source

Arguments

  • $to (string, array, craft\elements\User, 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

static – Self reference

# Protected Methods

Method Description
createSwiftMessage() Creates the Swift email message instance.
createSwiftSigner() Creates signer from its configuration
setBody() Sets the message body.