0 follower

Interface Yiisoft\Mailer\MessageInterface

ExtendsStringable
Implemented byYiisoft\Mailer\Message

MessageInterface is the interface that should be implemented by mail message classes.

A message represents the settings and content of an email, such as the sender, recipient, subject, body, etc.

Messages are sent by a {@see \Yiisoft\Mailer\MailerInterface}, like the following:

$message = (new Message())
    ->withFrom('from@domain.com')
    ->withTo('to@domain.com')
    ->withSubject('Message subject')
    ->withTextBody('Plain text content')
    ->withHtmlBody('<b>HTML content</b>')
;
$mailer->send($message);

Stringable implementation need for debug purposes only. Method __toString() should return string representation of message.

Public Methods

Hide inherited methods

Method Description Defined By
getAttachments() Yiisoft\Mailer\MessageInterface
getBcc() Returns the Bcc (hidden copy receiver) addresses of this message. Yiisoft\Mailer\MessageInterface
getCc() Returns the Cc (additional copy receiver) addresses of this message. Yiisoft\Mailer\MessageInterface
getCharset() Returns the charset of this message. Yiisoft\Mailer\MessageInterface
getDate() Returns the date when the message was sent, or null if it was not set. Yiisoft\Mailer\MessageInterface
getEmbeddings() Yiisoft\Mailer\MessageInterface
getFrom() Returns the message sender email address. Yiisoft\Mailer\MessageInterface
getHeader() Returns all values for the specified header. Yiisoft\Mailer\MessageInterface
getHeaders() Yiisoft\Mailer\MessageInterface
getHtmlBody() Returns the message HTML body. Yiisoft\Mailer\MessageInterface
getPriority() Returns the priority of this message. Yiisoft\Mailer\MessageInterface
getReplyTo() Returns the reply-to address of this message. Yiisoft\Mailer\MessageInterface
getReturnPath() Returns the return-path (the bounce address) of this message. Yiisoft\Mailer\MessageInterface
getSender() Returns the message actual sender email address. Yiisoft\Mailer\MessageInterface
getSubject() Returns the message subject. Yiisoft\Mailer\MessageInterface
getTextBody() Returns the message text body. Yiisoft\Mailer\MessageInterface
getTo() Returns the message recipient(s) email address. Yiisoft\Mailer\MessageInterface
withAddedAttachments() Returns a new instance with the specified added attached files. Yiisoft\Mailer\MessageInterface
withAddedBcc() Returns a new instance with the specified Bcc (hidden copy receiver) address(es). Yiisoft\Mailer\MessageInterface
withAddedCc() Returns a new instance with the specified Cc (additional copy receiver) address(es). Yiisoft\Mailer\MessageInterface
withAddedEmbeddings() Returns a new instance with the specified added embedded files. Yiisoft\Mailer\MessageInterface
withAddedFrom() Returns a new instance with added sender email address(es). Yiisoft\Mailer\MessageInterface
withAddedHeader() Returns a new instance with the specified added custom header value. Yiisoft\Mailer\MessageInterface
withAddedReplyTo() Returns a new instance with added reply-to address(es). Yiisoft\Mailer\MessageInterface
withAddedTo() Returns a new instance with added recipient(s) email address. Yiisoft\Mailer\MessageInterface
withAttachments() Returns a new instance with the specified attached files. Yiisoft\Mailer\MessageInterface
withBcc() Returns a new instance with the specified Bcc (hidden copy receiver) addresses. Yiisoft\Mailer\MessageInterface
withCc() Returns a new instance with the specified Cc (additional copy receiver) addresses. Yiisoft\Mailer\MessageInterface
withCharset() Returns a new instance with the specified charset. Yiisoft\Mailer\MessageInterface
withDate() Returns a new instance with the specified date when the message was sent. Yiisoft\Mailer\MessageInterface
withEmbeddings() Returns a new instance with the specified embedded files. Yiisoft\Mailer\MessageInterface
withFrom() Returns a new instance with the specified sender email address. Yiisoft\Mailer\MessageInterface
withHeader() Returns a new instance with the specified custom header value. Yiisoft\Mailer\MessageInterface
withHeaders() Returns a new instance with the specified custom header values. Yiisoft\Mailer\MessageInterface
withHtmlBody() Returns a new instance with the specified message HTML content. Yiisoft\Mailer\MessageInterface
withPriority() Returns a new instance with the specified priority of this message. Yiisoft\Mailer\MessageInterface
withReplyTo() Returns a new instance with the specified reply-to address. Yiisoft\Mailer\MessageInterface
withReturnPath() Returns a new instance with the specified return-path (the bounce address) of this message. Yiisoft\Mailer\MessageInterface
withSender() Returns a new instance with the specified actual sender email address. Yiisoft\Mailer\MessageInterface
withSubject() Returns a new instance with the specified message subject. Yiisoft\Mailer\MessageInterface
withTextBody() Returns a new instance with the specified message plain text content. Yiisoft\Mailer\MessageInterface
withTo() Returns a new instance with the specified recipient(s) email address. Yiisoft\Mailer\MessageInterface
withoutAttachments() Returns a new instance without attached files. Yiisoft\Mailer\MessageInterface
withoutEmbeddings() Returns a new instance without embedded files. Yiisoft\Mailer\MessageInterface

Method Details

Hide inherited methods

getAttachments() public abstract method

public abstract Yiisoft\Mailer\File[]|null getAttachments ( )

                public function getAttachments(): array|null;

            
getBcc() public abstract method

Returns the Bcc (hidden copy receiver) addresses of this message.

See also withBcc().

public abstract string|string[]|null getBcc ( )
return string|string[]|null

The Bcc (hidden copy receiver) addresses of this message.

                public function getBcc(): array|string|null;

            
getCc() public abstract method

Returns the Cc (additional copy receiver) addresses of this message.

See also withCc().

public abstract string|string[]|null getCc ( )
return string|string[]|null

The Cc (additional copy receiver) addresses of this message.

                public function getCc(): array|string|null;

            
getCharset() public abstract method

Returns the charset of this message.

public abstract string|null getCharset ( )
return string|null

The charset of this message.

                public function getCharset(): string|null;

            
getDate() public abstract method

Returns the date when the message was sent, or null if it was not set.

public abstract DateTimeImmutable|null getDate ( )
return DateTimeImmutable|null

The date when the message was sent.

                public function getDate(): DateTimeImmutable|null;

            
getEmbeddings() public abstract method

public abstract Yiisoft\Mailer\File[]|null getEmbeddings ( )

                public function getEmbeddings(): array|null;

            
getFrom() public abstract method

Returns the message sender email address.

See also withFrom().

public abstract string|string[]|null getFrom ( )
return string|string[]|null

The sender email address.

                public function getFrom(): array|string|null;

            
getHeader() public abstract method

Returns all values for the specified header.

public abstract string[] getHeader ( string $name )
$name string

The header name.

return string[]

The header values list.

                public function getHeader(string $name): array;

            
getHeaders() public abstract method

public abstract array|null getHeaders ( )

                public function getHeaders(): array|null;

            
getHtmlBody() public abstract method

Returns the message HTML body.

public abstract string|null getHtmlBody ( )
return string|null

The message HTML body.

                public function getHtmlBody(): string|null;

            
getPriority() public abstract method

Returns the priority of this message.

public abstract \Yiisoft\Mailer\Priority|null getPriority ( )
return \Yiisoft\Mailer\Priority|null

The message priority.

                public function getPriority(): Priority|null;

            
getReplyTo() public abstract method

Returns the reply-to address of this message.

See also withReplyTo().

public abstract string|string[]|null getReplyTo ( )
return string|string[]|null

The reply-to address of this message.

                public function getReplyTo(): array|string|null;

            
getReturnPath() public abstract method

Returns the return-path (the bounce address) of this message.

public abstract string|null getReturnPath ( )
return string|null

The bounce email address.

                public function getReturnPath(): string|null;

            
getSender() public abstract method

Returns the message actual sender email address.

public abstract string|null getSender ( )
return string|null

The actual sender email address.

                public function getSender(): string|null;

            
getSubject() public abstract method

Returns the message subject.

public abstract string|null getSubject ( )
return string|null

The message subject.

                public function getSubject(): string|null;

            
getTextBody() public abstract method

Returns the message text body.

public abstract string|null getTextBody ( )
return string|null

The message text body.

                public function getTextBody(): string|null;

            
getTo() public abstract method

Returns the message recipient(s) email address.

See also withTo().

public abstract string|string[]|null getTo ( )
return string|string[]|null

The message recipients email address.

                public function getTo(): array|string|null;

            
withAddedAttachments() public abstract method

Returns a new instance with the specified added attached files.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has added the new attached files.

public abstract Yiisoft\Mailer\MessageInterface withAddedAttachments ( Yiisoft\Mailer\File $files )
$files Yiisoft\Mailer\File

The file instances.

                public function withAddedAttachments(File ...$files): static;

            
withAddedBcc() public abstract method

Returns a new instance with the specified Bcc (hidden copy receiver) address(es).

public abstract Yiisoft\Mailer\MessageInterface withAddedBcc ( string|string[] $bcc )
$bcc string|string[]

The hidden copy receiver email address(es).

                public function withAddedBcc(array|string $bcc): static;

            
withAddedCc() public abstract method

Returns a new instance with the specified Cc (additional copy receiver) address(es).

public abstract Yiisoft\Mailer\MessageInterface withAddedCc ( string|string[] $cc )
$cc string|string[]

The copy receiver email address(es).

                public function withAddedCc(array|string $cc): static;

            
withAddedEmbeddings() public abstract method

Returns a new instance with the specified added embedded files.

This method should be used when embedding images or other data in a message.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has added the new embedded files.

public abstract Yiisoft\Mailer\MessageInterface withAddedEmbeddings ( Yiisoft\Mailer\File $files )
$files Yiisoft\Mailer\File

The file instances.

                public function withAddedEmbeddings(File ...$files): static;

            
withAddedFrom() public abstract method

Returns a new instance with added sender email address(es).

public abstract Yiisoft\Mailer\MessageInterface withAddedFrom ( string|string[] $from )
$from string|string[]

The sender email address(es).

                public function withAddedFrom(array|string $from): static;

            
withAddedHeader() public abstract method

Returns a new instance with the specified added custom header value.

Several invocations of this method with the same name will add multiple header values.

public abstract Yiisoft\Mailer\MessageInterface withAddedHeader ( string $name, string $value )
$name string

The header name.

$value string

The header value.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new added custom header value.

                public function withAddedHeader(string $name, string $value): static;

            
withAddedReplyTo() public abstract method

Returns a new instance with added reply-to address(es).

public abstract Yiisoft\Mailer\MessageInterface withAddedReplyTo ( string|string[] $replyTo )
$replyTo string|string[]

The reply-to address(es).

                public function withAddedReplyTo(array|string $replyTo): static;

            
withAddedTo() public abstract method

Returns a new instance with added recipient(s) email address.

public abstract Yiisoft\Mailer\MessageInterface withAddedTo ( string|string[] $to )
$to string|string[]

The receiver email address.

                public function withAddedTo(array|string $to): static;

            
withAttachments() public abstract method

Returns a new instance with the specified attached files.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new attached files.

public abstract Yiisoft\Mailer\MessageInterface withAttachments ( Yiisoft\Mailer\File $files )
$files Yiisoft\Mailer\File

The file instances.

                public function withAttachments(File ...$files): static;

            
withBcc() public abstract method

Returns a new instance with the specified Bcc (hidden copy receiver) addresses.

public abstract Yiisoft\Mailer\MessageInterface withBcc ( string|string[] $bcc )
$bcc string|string[]

The 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].

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new Bcc (hidden copy receiver) addresses.

                public function withBcc(array|string|null $bcc): static;

            
withCc() public abstract method

Returns a new instance with the specified Cc (additional copy receiver) addresses.

public abstract Yiisoft\Mailer\MessageInterface withCc ( string|string[] $cc )
$cc string|string[]

The 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].

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new Cc (additional copy receiver) addresses.

                public function withCc(array|string $cc): static;

            
withCharset() public abstract method

Returns a new instance with the specified charset.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new charset.

public abstract Yiisoft\Mailer\MessageInterface withCharset ( string|null $charset )
$charset string|null

The charset name.

                public function withCharset(string|null $charset): static;

            
withDate() public abstract method

Returns a new instance with the specified date when the message was sent.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new date when the message was sent.

public abstract Yiisoft\Mailer\MessageInterface withDate ( DateTimeInterface|null $date )
$date DateTimeInterface|null

The date when the message was sent.

                public function withDate(DateTimeInterface|null $date): static;

            
withEmbeddings() public abstract method

Returns a new instance with the specified embedded files.

This method should be used when embedding images or other data in a message.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new embedded file.

public abstract Yiisoft\Mailer\MessageInterface withEmbeddings ( Yiisoft\Mailer\File $files )
$files Yiisoft\Mailer\File

The file instances.

                public function withEmbeddings(File ...$files): static;

            
withFrom() public abstract method

Returns a new instance with the specified sender email address.

public abstract Yiisoft\Mailer\MessageInterface withFrom ( string|string[]|null $from )
$from string|string[]|null

The 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].

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new sender email address.

                public function withFrom(array|string|null $from): static;

            
withHeader() public abstract method

Returns a new instance with the specified custom header value.

public abstract Yiisoft\Mailer\MessageInterface withHeader ( string $name, string|string[] $value )
$name string

The header name.

$value string|string[]

The header value or values.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new custom header value.

                public function withHeader(string $name, string|array $value): static;

            
withHeaders() public abstract method

Returns a new instance with the specified custom header values.

public abstract Yiisoft\Mailer\MessageInterface withHeaders ( array|null $headers )
$headers array|null

The headers in format: [name => value].

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new custom header values.

                public function withHeaders(array|null $headers): static;

            
withHtmlBody() public abstract method

Returns a new instance with the specified message HTML content.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new message HTML content.

public abstract Yiisoft\Mailer\MessageInterface withHtmlBody ( string|null $html )
$html string|null

Message HTML content.

                public function withHtmlBody(string|null $html): static;

            
withPriority() public abstract method

Returns a new instance with the specified priority of this message.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new message priority.

public abstract Yiisoft\Mailer\MessageInterface withPriority ( \Yiisoft\Mailer\Priority|null $priority )
$priority \Yiisoft\Mailer\Priority|null

The message priority.

                public function withPriority(Priority|null $priority): static;

            
withReplyTo() public abstract method

Returns a new instance with the specified reply-to address.

public abstract Yiisoft\Mailer\MessageInterface withReplyTo ( string|string[]|null $replyTo )
$replyTo string|string[]|null

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].

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new reply-to address.

                public function withReplyTo(array|string|null $replyTo): static;

            
withReturnPath() public abstract method

Returns a new instance with the specified return-path (the bounce address) of this message.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new return-path (the bounce address).

public abstract Yiisoft\Mailer\MessageInterface withReturnPath ( string|null $address )
$address string|null

The bounce email address.

                public function withReturnPath(string|null $address): static;

            
withSender() public abstract method

Returns a new instance with the specified actual sender email address.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new actual sender email address.

public abstract Yiisoft\Mailer\MessageInterface withSender ( string|null $address )
$address string|null

The actual sender email address.

                public function withSender(string|null $address): static;

            
withSubject() public abstract method

Returns a new instance with the specified message subject.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new message subject.

public abstract Yiisoft\Mailer\MessageInterface withSubject ( string|null $subject )
$subject string|null

The message subject.

                public function withSubject(string|null $subject): static;

            
withTextBody() public abstract method

Returns a new instance with the specified message plain text content.

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new message plain text content.

public abstract Yiisoft\Mailer\MessageInterface withTextBody ( string|null $text )
$text string|null

The message plain text content.

                public function withTextBody(string|null $text): static;

            
withTo() public abstract method

Returns a new instance with the specified recipient(s) email address.

public abstract Yiisoft\Mailer\MessageInterface withTo ( string|string[]|null $to )
$to string|string[]|null

The 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].

This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the new recipients email address.

                public function withTo(array|string|null $to): static;

            
withoutAttachments() public abstract method

Returns a new instance without attached files.

public abstract Yiisoft\Mailer\MessageInterface withoutAttachments ( )

                public function withoutAttachments(): static;

            
withoutEmbeddings() public abstract method

Returns a new instance without embedded files.

public abstract Yiisoft\Mailer\MessageInterface withoutEmbeddings ( )

                public function withoutEmbeddings(): static;