Class yii\swiftmailer\Message

Inheritanceyii\swiftmailer\Message » yii\mail\BaseMessage » yii\base\BaseObject
Implementsyii\base\Configurable, yii\mail\MessageInterface
Available since version2.0
Source Code https://github.com/yiisoft/yii2-swiftmailer/blob/master/Message.php

Message implements a message class based on SwiftMailer.

See also:

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$bcc string|array The Bcc (hidden copy receiver) addresses of this message. yii\swiftmailer\Message
$cc string|array The Cc (additional copy receiver) addresses of this message. yii\swiftmailer\Message
$charset string The character set of this message. yii\swiftmailer\Message
$from string|array The sender yii\swiftmailer\Message
$headers array Headers in format: [name => value]. yii\swiftmailer\Message
$htmlBody string Message HTML content. yii\swiftmailer\Message
$mailer yii\mail\MailerInterface The mailer instance that created this message. yii\mail\BaseMessage
$priority integer Priority value, should be an integer in range: `1. yii\swiftmailer\Message
$readReceiptTo string|array Receipt receive email address(es). yii\swiftmailer\Message
$replyTo string|array The reply-to address of this message. yii\swiftmailer\Message
$returnPath string The bounce email address. yii\swiftmailer\Message
$signature array|callable|\Swift_Signer Signature specification. yii\swiftmailer\Message
$subject string The message subject yii\swiftmailer\Message
$swiftMessage \Swift_Message Swift message instance. yii\swiftmailer\Message
$textBody string Message plain text content. yii\swiftmailer\Message
$to string|array The message recipients yii\swiftmailer\Message

Public Methods

Hide inherited methods

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

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
createSwiftMessage() Creates the Swift email message instance. yii\swiftmailer\Message
createSwiftSigner() Creates signer from its configuration yii\swiftmailer\Message
setBody() Sets the message body. yii\swiftmailer\Message

Property Details

$bcc public property

The Bcc (hidden copy receiver) addresses of this message.

public string|array getBcc ( )
public $this setBcc ( $bcc )
$cc public property

The Cc (additional copy receiver) addresses of this message.

public string|array getCc ( )
public $this setCc ( $cc )
$charset public property

The character set of this message.

public string getCharset ( )
public $this setCharset ( $charset )
$from public property

The sender

public string|array getFrom ( )
public $this setFrom ( $from )
$headers public write-only property

Headers in format: [name => value].

public $this setHeaders ( $headers )
$htmlBody public write-only property

Message HTML content.

public $this setHtmlBody ( $html )
$priority public property

Priority value, should be an integer in range: 1..5, where 1 is the highest priority and 5 is the lowest.

public integer getPriority ( )
public $this setPriority ( $priority )
$readReceiptTo public property

Receipt receive email address(es).

public string getReadReceiptTo ( )
public $this setReadReceiptTo ( $addresses )
$replyTo public property

The reply-to address of this message.

public string|array getReplyTo ( )
public $this setReplyTo ( $replyTo )
$returnPath public property

The bounce email address.

public string getReturnPath ( )
public $this setReturnPath ( $address )
$signature public write-only property

Signature specification. See addSignature() for details on how it should be specified.

public $this setSignature ( $signature )
$subject public property

The message subject

public string getSubject ( )
public $this setSubject ( $subject )
$swiftMessage public read-only property

Swift message instance.

public \Swift_Message getSwiftMessage ( )
$textBody public write-only property

Message plain text content.

public $this setTextBody ( $text )
$to public property

The message recipients

public string|array getTo ( )
public $this setTo ( $to )

Method Details

__clone() public method (available since version 2.0.7)

This method is called after the object is created by cloning an existing one.

It ensures $swiftMessage is also cloned.

public void __clone ( )
addHeader() public method (available since version 2.0.6)

Adds custom header value to the message.

Several invocations of this method with the same name will add multiple header values.

public $this addHeader ( $name, $value )
$name string

Header name.

$value string

Header value.

return $this

Self reference.

addSignature() public method (available since version 2.0.6)

Adds message signature.

public $this addSignature ( $signature )
$signature array|callable|\Swift_Signer

Signature specification, this can be:

  • \Swift_Signer instance
  • callable, which returns \Swift_Signer instance
  • configuration array for the signer creation
return $this

Self reference

throws yii\base\InvalidConfigException

on invalid signature configuration

attach() public method

Attaches existing file to the email message.

public $this attach ( $fileName, array $options = [] )
$fileName string

Full file name

$options array

Options for embed file. Valid options are:

  • fileName: name, which should be used to attach file.
  • contentType: attached file MIME type.
return $this

Self reference.

attachContent() public method

Attach specified content as file for the email message.

public $this attachContent ( $content, array $options = [] )
$content string

Attachment file content.

$options array

Options for embed file. Valid options are:

  • fileName: name, which should be used to attach file.
  • contentType: attached file MIME type.
return $this

Self reference.

createSwiftMessage() protected method

Creates the Swift email message instance.

protected \Swift_Message createSwiftMessage ( )
return \Swift_Message

Email message instance.

createSwiftSigner() protected method (available since version 2.0.6)

Creates signer from its configuration

protected \Swift_Signer createSwiftSigner ( $signature )
$signature array

Signature configuration

return \Swift_Signer

Signer instance

throws yii\base\InvalidConfigException

on invalid configuration provided

embed() public method

Attach a file and return it's CID source.

This method should be used when embedding images or other data in a message.

public string embed ( $fileName, array $options = [] )
$fileName string

File name.

$options array

Options for embed file. Valid options are:

  • fileName: name, which should be used to attach file.
  • contentType: attached file MIME type.
return string

Attachment CID.

embedContent() public method

Attach a content as file and return it's CID source.

This method should be used when embedding images or other data in a message.

public string embedContent ( $content, array $options = [] )
$content string

Attachment file content.

$options array

Options for embed file. Valid options are:

  • fileName: name, which should be used to attach file.
  • contentType: attached file MIME type.
return string

Attachment CID.

getBcc() public method

Returns the Bcc (hidden copy receiver) addresses of this message.

public string|array getBcc ( )
return string|array

The Bcc (hidden copy receiver) addresses of this message.

getCc() public method

Returns the Cc (additional copy receiver) addresses of this message.

public string|array getCc ( )
return string|array

The Cc (additional copy receiver) addresses of this message.

getCharset() public method

Returns the character set of this message.

public string getCharset ( )
return string

The character set of this message.

getFrom() public method

Returns the message sender.

public string|array getFrom ( )
return string|array

The sender

getHeader() public method (available since version 2.0.6)

Returns all values for the specified header.

public array getHeader ( $name )
$name string

Header name.

return array

Header values list.

getPriority() public method (available since version 2.0.6)

Returns the priority of this message.

public integer getPriority ( )
return integer

Priority value as integer in range: 1..5, where 1 is the highest priority and 5 is the lowest.

getReadReceiptTo() public method (available since version 2.0.6)

Get the addresses to which a read-receipt will be sent.

public string getReadReceiptTo ( )
return string

Receipt receive email addresses.

getReplyTo() public method

Returns the reply-to address of this message.

public string|array getReplyTo ( )
return string|array

The reply-to address of this message.

getReturnPath() public method (available since version 2.0.6)

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

public string getReturnPath ( )
return string

The bounce email address.

getSubject() public method

Returns the message subject.

public string getSubject ( )
return string

The message subject

getSwiftMessage() public method

public \Swift_Message getSwiftMessage ( )
return \Swift_Message

Swift message instance.

getTo() public method

Returns the message recipient(s).

public string|array getTo ( )
return string|array

The message recipients

setBcc() public method

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

public $this setBcc ( $bcc )
$bcc string|array

Hidden copy receiver email address. 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].

return $this

Self reference.

setBody() protected method

Sets the message body.

If body is already set and its content type matches given one, it will be overridden, if content type miss match the multipart message will be composed.

protected void setBody ( $body, $contentType )
$body string

Body content.

$contentType string

Body content type.

setCc() public method

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

public $this setCc ( $cc )
$cc string|array

Copy receiver email address. 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].

return $this

Self reference.

setCharset() public method

Sets the character set of this message.

public $this setCharset ( $charset )
$charset string

Character set name.

return $this

Self reference.

setFrom() public method

Sets the message sender.

public $this setFrom ( $from )
$from string|array

Sender email address. 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].

return $this

Self reference.

setHeader() public method (available since version 2.0.6)

Sets custom header value to the message.

public $this setHeader ( $name, $value )
$name string

Header name.

$value string|array

Header value or values.

return $this

Self reference.

setHeaders() public method (available since version 2.0.7)

Sets custom header values to the message.

public $this setHeaders ( $headers )
$headers array

Headers in format: [name => value].

return $this

Self reference.

setHtmlBody() public method

Sets message HTML content.

public $this setHtmlBody ( $html )
$html string

Message HTML content.

return $this

Self reference.

setPriority() public method (available since version 2.0.6)

Set the priority of this message.

public $this setPriority ( $priority )
$priority integer

Priority value, should be an integer in range: 1..5, where 1 is the highest priority and 5 is the lowest.

return $this

Self reference.

setReadReceiptTo() public method (available since version 2.0.6)

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

public $this setReadReceiptTo ( $addresses )
$addresses string|array

Receipt receive email address(es).

return $this

Self reference.

setReplyTo() public method

Sets the reply-to address of this message.

public $this setReplyTo ( $replyTo )
$replyTo string|array

The reply-to address. You may pass an array of addresses if this message should be replied to multiple people. You may also specify reply-to name in addition to email address using format: [email => name].

return $this

Self reference.

setReturnPath() public method (available since version 2.0.6)

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

public $this setReturnPath ( $address )
$address string

The bounce email address.

return $this

Self reference.

setSignature() public method (available since version 2.0.6)

Sets message signature

public $this setSignature ( $signature )
$signature array|callable|\Swift_Signer

Signature specification. See addSignature() for details on how it should be specified.

return $this

Self reference.

setSubject() public method

Sets the message subject.

public $this setSubject ( $subject )
$subject string

Message subject

return $this

Self reference.

setTextBody() public method

Sets message plain text content.

public $this setTextBody ( $text )
$text string

Message plain text content.

return $this

Self reference.

setTo() public method

Sets the message recipient(s).

public $this setTo ( $to )
$to string|array

Receiver email address. 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].

return $this

Self reference.

toString() public method

Returns string representation of this message.

public string toString ( )
return string

The string representation of this message.