Abstract Class yii\mail\BaseMessage

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

BaseMessage serves as a base class that implements the send() method required by yii\mail\MessageInterface.

By default, send() will use the "mailer" application component to send the current message. The "mailer" application component should be a mailer instance implementing yii\mail\MailerInterface.

See also yii\mail\BaseMailer.

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$bcc string|array The Bcc (hidden copy receiver) addresses of this message. yii\mail\MessageInterface
$cc string|array The Cc (additional copy receiver) addresses of this message. yii\mail\MessageInterface
$charset string The character set of this message. yii\mail\MessageInterface
$from string|array The sender yii\mail\MessageInterface
$htmlBody string Message HTML content. yii\mail\MessageInterface
$mailer yii\mail\MailerInterface The mailer instance that created this message. yii\mail\BaseMessage
$replyTo string|array The reply-to address of this message. yii\mail\MessageInterface
$subject string The message subject yii\mail\MessageInterface
$textBody string Message plain text content. yii\mail\MessageInterface
$to string|array The message recipients yii\mail\MessageInterface

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__call() Calls the named method which is not a class method. yii\base\BaseObject
__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
attach() Attaches existing file to the email message. yii\mail\MessageInterface
attachContent() Attach specified content as file for the email message. yii\mail\MessageInterface
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\mail\MessageInterface
embedContent() Attach a content as file and return it's CID source. yii\mail\MessageInterface
getBcc() Returns the Bcc (hidden copy receiver) addresses of this message. yii\mail\MessageInterface
getCc() Returns the Cc (additional copy receiver) addresses of this message. yii\mail\MessageInterface
getCharset() Returns the character set of this message. yii\mail\MessageInterface
getFrom() Returns the message sender. yii\mail\MessageInterface
getReplyTo() Returns the reply-to address of this message. yii\mail\MessageInterface
getSubject() Returns the message subject. yii\mail\MessageInterface
getTo() Returns the message recipient(s). yii\mail\MessageInterface
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\mail\MessageInterface
setCc() Sets the Cc (additional copy receiver) addresses of this message. yii\mail\MessageInterface
setCharset() Sets the character set of this message. yii\mail\MessageInterface
setFrom() Sets the message sender. yii\mail\MessageInterface
setHtmlBody() Sets message HTML content. yii\mail\MessageInterface
setReplyTo() Sets the reply-to address of this message. yii\mail\MessageInterface
setSubject() Sets the message subject. yii\mail\MessageInterface
setTextBody() Sets message plain text content. yii\mail\MessageInterface
setTo() Sets the message recipient(s). yii\mail\MessageInterface
toString() Returns string representation of this message. yii\mail\MessageInterface

Property Details

$mailer public property

The mailer instance that created this message. For independently created messages this is null.

Method Details

__toString() public method

PHP magic method that returns the string representation of this object.

public string __toString ( )
return string

The string representation of this object.

send() public method

Sends this email message.

public boolean send ( yii\mail\MailerInterface $mailer null )
$mailer yii\mail\MailerInterface

The mailer that should be used to send this message. If no mailer is given it will first check if $mailer is set and if not, the "mailer" application component will be used instead.

return boolean

Whether this message is sent successfully.