W3cubDocs

/Yii 2.0

Abstract Class yii\mail\BaseMessage

Inheritance yii\mail\BaseMessage » yii\base\Object
Implements yii\base\Configurable, yii\mail\MessageInterface
Subclasses yii\swiftmailer\Message
Available since version 2.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 "mail" application component to send the current message. The "mail" application component should be a mailer instance implementing yii\mail\MailerInterface.

See also yii\mail\BaseMailer.

Public Properties

Property Type Description Defined By
$bcc array The Bcc (hidden copy receiver) addresses of this message. yii\mail\MessageInterface
$cc 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 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 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 array The message recipients yii\mail\MessageInterface

Public Methods

Method Description Defined By
__call() Calls the named method which is not a class method. yii\base\Object
__construct() Constructor. yii\base\Object
__get() Returns the value of an object property. yii\base\Object
__isset() Checks if a property is set, i.e. defined and not null. yii\base\Object
__set() Sets value of an object property. yii\base\Object
__toString() PHP magic method that returns the string representation of this object. yii\mail\BaseMessage
__unset() Sets an object property to null. yii\base\Object
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\Object
canSetProperty() Returns a value indicating whether a property can be set. yii\base\Object
className() Returns the fully qualified name of this class. yii\base\Object
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\Object
hasProperty() Returns a value indicating whether a property is defined. yii\base\Object
init() Initializes the object. yii\base\Object
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.

public yii\mail\MailerInterface $mailer = 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 "mail" application component will be used instead.

return boolean

Whether this message is sent successfully.

© 2008–2017 by Yii Software LLC
Licensed under the three clause BSD license.
http://www.yiiframework.com/doc-2.0/yii-mail-basemessage.html