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

Represents an email message.

View source

Public Properties

PropertyDescription
$bccstring, array – The Bcc (hidden copy receiver) addresses of this message.
$ccstring, array – The Cc (additional copy receiver) addresses of this message.
$charsetstring – The character set of this message.
$fromstring, array – The sender
$headersarray – Headers in format: [name => value].
$htmlBodystring – Message HTML content.
$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
$maileryii\mail\MailerInterface – The mailer instance that created this message.
$priorityinteger – Priority value, should be an integer in range: `1.
$readReceiptTostring, array – Receipt receive email address(es).
$replyTostring, array – The reply-to address of this message.
$returnPathstring – The bounce email address.
$signaturearray, callable, \Swift_Signer – Signature specification.
$subjectstring – The message subject
$swiftMessage\Swift_Message – Swift message instance.
$textBodystring – Message plain text content.
$tostring, array – The message recipients
$variablesarray, 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

Signature

public string, null $key = null

$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

Signature

public string, null $language = null

$variables

Type
array, null

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

View source

Signature

public array, null $variables = null

Public Methods

MethodDescription
__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 address of this message.
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’ 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

Signature

public static setBcc ( $bcc )

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

Signature

public static setCc ( $cc )

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

Signature

public static setFrom ( $from )

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

Signature

public static setTo ( $to )

Protected Methods

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