Skip to content
PHP Ecosystem
Explore

BaseMessage

API reference › yii › mail › BaseMessage

abstract classyii\mail\BaseMessage
Extendsyii\base\BaseObject
ImplementsMessageInterface, yii\base\Configurable
Since2.0
Sourceframework/mail/BaseMessage.php

BaseMessage serves as a base class that implements the send() method required by 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 MailerInterface.

See also: BaseMailer.

PropertyTypeDescriptionDefined by
$bccstring|arrayThe Bcc (hidden copy receiver) addresses of this message.MessageInterface
$ccstring|arrayThe Cc (additional copy receiver) addresses of this message.MessageInterface
$charsetstringThe character set of this message.MessageInterface
$fromstring|arrayThe senderMessageInterface
$htmlBody write-onlystringMessage HTML content.MessageInterface
$mailerMailerInterface|nullThe mailer instance that created this message. Default: null.BaseMessage
$replyTostring|arrayThe reply-to address of this message.MessageInterface
$subjectstringThe message subjectMessageInterface
$textBody write-onlystringMessage plain text content.MessageInterface
$tostring|arrayThe message recipientsMessageInterface
MethodDescriptionDefined by
__construct()Constructor.yii\base\BaseObject
__call()Calls the named method which is not a class method.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.BaseMessage
__unset()Sets an object property to null.yii\base\BaseObject
attach() abstractAttaches existing file to the email message.MessageInterface
attachContent() abstractAttach specified content as file for the email message.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() staticReturns the fully qualified name of this class.yii\base\BaseObject
embed() abstractAttach a file and return it’s CID source.MessageInterface
embedContent() abstractAttach a content as file and return it’s CID source.MessageInterface
getBcc() abstractReturns the Bcc (hidden copy receiver) addresses of this message.MessageInterface
getCc() abstractReturns the Cc (additional copy receiver) addresses of this message.MessageInterface
getCharset() abstractReturns the character set of this message.MessageInterface
getFrom() abstractReturns the message sender.MessageInterface
getReplyTo() abstractReturns the reply-to address of this message.MessageInterface
getSubject() abstractReturns the message subject.MessageInterface
getTo() abstractReturns the message recipient(s).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.BaseMessage
setBcc() abstractSets the Bcc (hidden copy receiver) addresses of this message.MessageInterface
setCc() abstractSets the Cc (additional copy receiver) addresses of this message.MessageInterface
setCharset() abstractSets the character set of this message.MessageInterface
setFrom() abstractSets the message sender.MessageInterface
setHtmlBody() abstractSets message HTML content.MessageInterface
setReplyTo() abstractSets the reply-to address of this message.MessageInterface
setSubject() abstractSets the message subject.MessageInterface
setTextBody() abstractSets message plain text content.MessageInterface
setTo() abstractSets the message recipient(s).MessageInterface
toString() abstractReturns string representation of this message.MessageInterface
public yii\mail\MailerInterface|null $mailer = null

The mailer instance that created this message.

For independently created messages this is null.

public function __toString(): string

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

Returns

string: The string representation of this object.

public function send(yii\mail\MailerInterface|null $mailer = null): bool

Sends this email message.

Parameters

ParameterTypeDescription
$mailerMailerInterface|nullThe 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.

Returns

bool: Whether this message is sent successfully.