Message

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

Represents an email message.

View source (opens new window)

# Public Properties

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

# error

Type
\craft\mail\Swift_TransportException, null (opens new window)
Default value
null

The caught error object, if the message failed to send

View source (opens new window)

# key

Type
string (opens new window), null (opens new window)
Default value
null

The key of the message that should be loaded

View source (opens new window)

# language

Type
string (opens new window), null (opens new window)
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 (opens new window)

# variables

Type
array (opens new window), null (opens new window)
Default value
null

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

View source (opens new window)

# Public Methods

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

# setBcc()

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

View source (opens new window)

Arguments

Returns

static – Self reference

# setCc()

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

View source (opens new window)

Arguments

Returns

static – Self reference

# setFrom()

Sets the message sender.

View source (opens new window)

Arguments

Returns

static – Self reference

# setReplyTo()

Since
3.4.0

Sets the Reply-To email.

View source (opens new window)

Arguments

Returns

static – Self reference

# setTo()

Sets the message recipient(s).

View source (opens new window)

Arguments

Returns

static – Self reference

# Protected Methods

Method Description
createSwiftMessage() (opens new window) Creates the Swift email message instance.
createSwiftSigner() (opens new window) Creates signer from it's configuration.
setBody() (opens new window) Sets the message body.