BaseMessage
API reference › yii › mail › BaseMessage
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.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$bcc | string| | The Bcc (hidden copy receiver) addresses of this message. | MessageInterface |
$cc | string| | The Cc (additional copy receiver) addresses of this message. | MessageInterface |
$charset | string | The character set of this message. | MessageInterface |
$from | string| | The sender | MessageInterface |
$htmlBody write-only | string | Message HTML content. | MessageInterface |
$mailer | MailerInterface| | The mailer instance that created this message. Default: null. | BaseMessage |
$replyTo | string| | The reply-to address of this message. | MessageInterface |
$subject | string | The message subject | MessageInterface |
$textBody write-only | string | Message plain text content. | MessageInterface |
$to | string| | The message recipients | MessageInterface |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__toString() | PHP magic method that returns the string representation of this object. | BaseMessage |
__unset() | Sets an object property to null. | yii\ |
attach() abstract | Attaches existing file to the email message. | MessageInterface |
attachContent() abstract | Attach specified content as file for the email message. | MessageInterface |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
embed() abstract | Attach a file and return it’s CID source. | MessageInterface |
embedContent() abstract | Attach a content as file and return it’s CID source. | MessageInterface |
getBcc() abstract | Returns the Bcc (hidden copy receiver) addresses of this message. | MessageInterface |
getCc() abstract | Returns the Cc (additional copy receiver) addresses of this message. | MessageInterface |
getCharset() abstract | Returns the character set of this message. | MessageInterface |
getFrom() abstract | Returns the message sender. | MessageInterface |
getReplyTo() abstract | Returns the reply-to address of this message. | MessageInterface |
getSubject() abstract | Returns the message subject. | MessageInterface |
getTo() abstract | Returns the message recipient(s). | MessageInterface |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
send() | Sends this email message. | BaseMessage |
setBcc() abstract | Sets the Bcc (hidden copy receiver) addresses of this message. | MessageInterface |
setCc() abstract | Sets the Cc (additional copy receiver) addresses of this message. | MessageInterface |
setCharset() abstract | Sets the character set of this message. | MessageInterface |
setFrom() abstract | Sets the message sender. | MessageInterface |
setHtmlBody() abstract | Sets message HTML content. | MessageInterface |
setReplyTo() abstract | Sets the reply-to address of this message. | MessageInterface |
setSubject() abstract | Sets the message subject. | MessageInterface |
setTextBody() abstract | Sets message plain text content. | MessageInterface |
setTo() abstract | Sets the message recipient(s). | MessageInterface |
toString() abstract | Returns string representation of this message. | MessageInterface |
Property details
Section titled “Property details”$mailer
Section titled “$mailer ”public yii\mail\MailerInterface|null $mailer = nullThe mailer instance that created this message.
For independently created messages this is null.
Method details
Section titled “Method details”__toString()
Section titled “__toString() ”public function __toString(): stringPHP magic method that returns the string representation of this object.
Returns
string: The string representation of this object.
send()
Section titled “send() ”public function send(yii\mail\MailerInterface|null $mailer = null): boolSends this email message.
Parameters
| Parameter | Type | Description |
|---|---|---|
$mailer | 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. |
Returns
bool: Whether this message is sent successfully.