Message
extends Message
in package
Message
Tags
Table of Contents
Properties
- $mailer : MailerInterface|null
- $charset : string
- $email : Email
Methods
- __call() : mixed
- Calls the named method which is not a class method.
- __clone() : mixed
- __construct() : mixed
- Constructor.
- __get() : mixed
- Returns the value of an object property.
- __isset() : bool
- Checks if a property is set, i.e. defined and not null.
- __set() : mixed
- Sets value of an object property.
- __toString() : string
- PHP magic method that returns the string representation of this object.
- __unset() : mixed
- Sets an object property to null.
- addHeader() : self
- attach() : $this
- Attaches existing file to the email message.
- attachContent() : $this
- Attach specified content as file for the email message.
- canGetProperty() : bool
- Returns a value indicating whether a property can be read.
- canSetProperty() : bool
- Returns a value indicating whether a property can be set.
- className() : string
- Returns the fully qualified name of this class.
- embed() : string
- Attach a file and return it's CID source.
- embedContent() : string
- Attach a content as file and return it's CID source.
- getBcc() : string|array<string|int, mixed>
- Returns the Bcc (hidden copy receiver) addresses of this message.
- getCc() : string|array<string|int, mixed>
- Returns the Cc (additional copy receiver) addresses of this message.
- getCharset() : string
- Returns the character set of this message.
- getDate() : DateTimeImmutable|null
- getFrom() : string|array<string|int, mixed>
- Returns the message sender.
- getHeader() : array<string|int, mixed>
- getHtmlBody() : string
- getPriority() : int
- getReplyTo() : string|array<string|int, mixed>
- Returns the reply-to address of this message.
- getReturnPath() : string
- getSender() : string
- getSubject() : string
- Returns the message subject.
- getSymfonyEmail() : Email
- Returns a Symfony email instance.
- getTextBody() : string
- getTo() : string|array<string|int, mixed>
- Returns the message recipient(s).
- hasMethod() : bool
- Returns a value indicating whether a method is defined.
- hasProperty() : bool
- Returns a value indicating whether a property is defined.
- init() : mixed
- Initializes the object.
- send() : bool
- Sends this email message.
- setBcc() : $this
- Sets the Bcc (hidden copy receiver) addresses of this message.
- setCc() : $this
- Sets the Cc (additional copy receiver) addresses of this message.
- setCharset() : $this
- Sets the character set of this message.
- setDate() : self
- setFrom() : $this
- Sets the message sender.
- setHeader() : self
- setHeaders() : self
- setHtmlBody() : $this
- Sets message HTML content.
- setPriority() : self
- setReplyTo() : $this
- Sets the reply-to address of this message.
- setReturnPath() : self
- setSender() : self
- setSubject() : $this
- Sets the message subject.
- setTextBody() : $this
- Sets message plain text content.
- setTo() : $this
- Sets the message recipient(s).
- toString() : string
- Returns string representation of this message.
- convertAddressesToStrings() : array<string, string>|string
- Converts address instances to their string representations.
- convertStringsToAddresses() : array<string|int, Address>
- Converts string representations of address to their instances.
Properties
$mailer
public
MailerInterface|null
$mailer
the mailer instance that created this message.
For independently created messages this is null
.
$charset
private
string
$charset
= 'utf-8'
private
Email
$email
Methods
__call()
Calls the named method which is not a class method.
public
__call(string $name, array<string|int, mixed> $params) : mixed
Do not call this method directly as it is a PHP magic method that will be implicitly called when an unknown method is being invoked.
Parameters
- $name : string
-
the method name
- $params : array<string|int, mixed>
-
method parameters
Tags
Return values
mixed —the method return value
__clone()
public
__clone() : mixed
__construct()
Constructor.
public
__construct([mixed $config = [] ]) : mixed
The default implementation does two things:
- Initializes the object with the given configuration
$config
. - Call [[init()]].
If this method is overridden in a child class, it is recommended that
- the last parameter of the constructor is a configuration array, like
$config
here. - call the parent implementation at the end of the constructor.
Parameters
- $config : mixed = []
-
name-value pairs that will be used to initialize the object properties
__get()
Returns the value of an object property.
public
__get(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $value = $object->property;
.
Parameters
- $name : string
-
the property name
Tags
Return values
mixed —the property value
__isset()
Checks if a property is set, i.e. defined and not null.
public
__isset(string $name) : bool
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing isset($object->property)
.
Note that if the property is not defined, false will be returned.
Parameters
- $name : string
-
the property name or the event name
Tags
Return values
bool —whether the named property is set (not null).
__set()
Sets value of an object property.
public
__set(string $name, mixed $value) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing $object->property = $value;
.
Parameters
- $name : string
-
the property name or the event name
- $value : mixed
-
the property value
Tags
__toString()
PHP magic method that returns the string representation of this object.
public
__toString() : string
Return values
string —the string representation of this object.
__unset()
Sets an object property to null.
public
__unset(string $name) : mixed
Do not call this method directly as it is a PHP magic method that
will be implicitly called when executing unset($object->property)
.
Note that if the property is not defined, this method will do nothing. If the property is read-only, it will throw an exception.
Parameters
- $name : string
-
the property name
Tags
addHeader()
public
addHeader(mixed $name, mixed $value) : self
Parameters
- $name : mixed
- $value : mixed
Return values
selfattach()
Attaches existing file to the email message.
public
attach(mixed $fileName[, array<string|int, mixed> $options = [] ]) : $this
Parameters
- $fileName : mixed
-
full file name
- $options : array<string|int, mixed> = []
-
options for embed file. Valid options are:
- fileName: name, which should be used to attach file.
- contentType: attached file MIME type.
Tags
Return values
$this —self reference.
attachContent()
Attach specified content as file for the email message.
public
attachContent(mixed $content[, array<string|int, mixed> $options = [] ]) : $this
Parameters
- $content : mixed
-
attachment file content.
- $options : array<string|int, mixed> = []
-
options for embed file. Valid options are:
- fileName: name, which should be used to attach file.
- contentType: attached file MIME type.
Tags
Return values
$this —self reference.
canGetProperty()
Returns a value indicating whether a property can be read.
public
canGetProperty(string $name[, bool $checkVars = true ]) : bool
A property is readable if:
- the class has a getter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be read
canSetProperty()
Returns a value indicating whether a property can be set.
public
canSetProperty(string $name[, bool $checkVars = true ]) : bool
A property is writable if:
- the class has a setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property can be written
className()
Returns the fully qualified name of this class.
public
static className() : string
Tags
Return values
string —the fully qualified name of this class.
embed()
Attach a file and return it's CID source.
public
embed(mixed $fileName[, array<string|int, mixed> $options = [] ]) : string
Parameters
- $fileName : mixed
-
file name.
- $options : array<string|int, mixed> = []
-
options for embed file. Valid options are:
- fileName: name, which should be used to attach file.
- contentType: attached file MIME type.
Tags
Return values
string —attachment CID.
embedContent()
Attach a content as file and return it's CID source.
public
embedContent(mixed $content[, array<string|int, mixed> $options = [] ]) : string
Parameters
- $content : mixed
-
attachment file content.
- $options : array<string|int, mixed> = []
-
options for embed file. Valid options are:
- fileName: name, which should be used to attach file.
- contentType: attached file MIME type.
Tags
Return values
string —attachment CID.
getBcc()
Returns the Bcc (hidden copy receiver) addresses of this message.
public
getBcc() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed> —the Bcc (hidden copy receiver) addresses of this message.
getCc()
Returns the Cc (additional copy receiver) addresses of this message.
public
getCc() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed> —the Cc (additional copy receiver) addresses of this message.
getCharset()
Returns the character set of this message.
public
getCharset() : string
Return values
string —the character set of this message.
getDate()
public
getDate() : DateTimeImmutable|null
Return values
DateTimeImmutable|nullgetFrom()
Returns the message sender.
public
getFrom() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed> —the sender
getHeader()
public
getHeader(mixed $name) : array<string|int, mixed>
Parameters
- $name : mixed
Return values
array<string|int, mixed>getHtmlBody()
public
getHtmlBody() : string
Return values
stringgetPriority()
public
getPriority() : int
Return values
intgetReplyTo()
Returns the reply-to address of this message.
public
getReplyTo() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed> —the reply-to address of this message.
getReturnPath()
public
getReturnPath() : string
Return values
stringgetSender()
public
getSender() : string
Return values
stringgetSubject()
Returns the message subject.
public
getSubject() : string
Return values
string —the message subject
getSymfonyEmail()
Returns a Symfony email instance.
public
getSymfonyEmail() : Email
Return values
Email —Symfony email instance.
getTextBody()
public
getTextBody() : string
Return values
stringgetTo()
Returns the message recipient(s).
public
getTo() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed> —the message recipients
hasMethod()
Returns a value indicating whether a method is defined.
public
hasMethod(string $name) : bool
The default implementation is a call to php function method_exists()
.
You may override this method when you implemented the php magic method __call()
.
Parameters
- $name : string
-
the method name
Return values
bool —whether the method is defined
hasProperty()
Returns a value indicating whether a property is defined.
public
hasProperty(string $name[, bool $checkVars = true ]) : bool
A property is defined if:
- the class has a getter or setter method associated with the specified name (in this case, property name is case-insensitive);
- the class has a member variable with the specified name (when
$checkVars
is true);
Parameters
- $name : string
-
the property name
- $checkVars : bool = true
-
whether to treat member variables as properties
Tags
Return values
bool —whether the property is defined
init()
Initializes the object.
public
init() : mixed
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
send()
Sends this email message.
public
send([MailerInterface|null $mailer = null ]) : bool
Parameters
- $mailer : MailerInterface|null = null
-
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 values
bool —whether this message is sent successfully.
setBcc()
Sets the Bcc (hidden copy receiver) addresses of this message.
public
setBcc(mixed $bcc) : $this
Parameters
- $bcc : mixed
-
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 values
$this —self reference.
setCc()
Sets the Cc (additional copy receiver) addresses of this message.
public
setCc(mixed $cc) : $this
Parameters
- $cc : mixed
-
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 values
$this —self reference.
setCharset()
Sets the character set of this message.
public
setCharset(mixed $charset) : $this
Parameters
- $charset : mixed
-
character set name.
Return values
$this —self reference.
setDate()
public
setDate(DateTimeInterface $date) : self
Parameters
- $date : DateTimeInterface
Return values
selfsetFrom()
Sets the message sender.
public
setFrom(mixed $from) : $this
Parameters
- $from : mixed
-
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 values
$this —self reference.
setHeader()
public
setHeader(mixed $name, mixed $value) : self
Parameters
- $name : mixed
- $value : mixed
Return values
selfsetHeaders()
public
setHeaders(mixed $headers) : self
Parameters
- $headers : mixed
Return values
selfsetHtmlBody()
Sets message HTML content.
public
setHtmlBody(mixed $html) : $this
Parameters
- $html : mixed
-
message HTML content.
Return values
$this —self reference.
setPriority()
public
setPriority(int $priority) : self
Parameters
- $priority : int
Return values
selfsetReplyTo()
Sets the reply-to address of this message.
public
setReplyTo(mixed $replyTo) : $this
Parameters
- $replyTo : mixed
-
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 values
$this —self reference.
setReturnPath()
public
setReturnPath(string $address) : self
Parameters
- $address : string
Return values
selfsetSender()
public
setSender(string $address) : self
Parameters
- $address : string
Return values
selfsetSubject()
Sets the message subject.
public
setSubject(mixed $subject) : $this
Parameters
- $subject : mixed
-
message subject
Return values
$this —self reference.
setTextBody()
Sets message plain text content.
public
setTextBody(mixed $text) : $this
Parameters
- $text : mixed
-
message plain text content.
Return values
$this —self reference.
setTo()
Sets the message recipient(s).
public
setTo(mixed $to) : $this
Parameters
- $to : mixed
-
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 values
$this —self reference.
toString()
Returns string representation of this message.
public
toString() : string
Return values
string —the string representation of this message.
convertAddressesToStrings()
Converts address instances to their string representations.
private
convertAddressesToStrings(array<string|int, Address> $addresses) : array<string, string>|string
Parameters
- $addresses : array<string|int, Address>
Return values
array<string, string>|stringconvertStringsToAddresses()
Converts string representations of address to their instances.
private
convertStringsToAddresses(array<int|string, string>|string $strings) : array<string|int, Address>
Parameters
- $strings : array<int|string, string>|string