Final Class Yiisoft\Mailer\MessageSettings
| Inheritance | Yiisoft\Mailer\MessageSettings |
|---|
MessageSettings provides default and extra message settings.
Psalm Types
| Name | Value |
|---|---|
| HtmlToTextBodyConverterCallable | callable |
Public Properties
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Mailer\MessageSettings | |
| applyTo() | Yiisoft\Mailer\MessageSettings |
Property Details
The custom headers in format [name => value[]] that will be added if there are
no corresponding headers in the message.
The HTML to text body converter.
The custom headers in format [name => value[]] that will always be added to message.
Method Details
| public mixed __construct ( string|null $charset = null, string|string[]|null $from = null, string|string[]|null $addFrom = null, string|string[]|null $to = null, string|string[]|null $addTo = null, string|string[]|null $replyTo = null, string|string[]|null $addReplyTo = null, string|string[]|null $cc = null, string|string[]|null $addCc = null, string|string[]|null $bcc = null, string|string[]|null $addBcc = null, string|null $subject = null, DateTimeImmutable|null $date = null, \Yiisoft\Mailer\Priority|null $priority = null, string|null $returnPath = null, string|null $sender = null, string|null $textBody = null, string|null $htmlBody = null, Yiisoft\Mailer\File[]|null $attachments = null, Yiisoft\Mailer\File[]|null $addAttachments = null, Yiisoft\Mailer\File[]|null $embeddings = null, Yiisoft\Mailer\File[]|null $addEmbeddings = null, array[]|null $headers = null, array[]|null $overwriteHeaders = null, callable|null $htmlToTextBodyConverter = null ) | ||
| $charset | string|null | |
| $from | string|string[]|null |
The sender email address(es). You may also specify sender name in addition
to email address using format: |
| $addFrom | string|string[]|null |
The sender email address(es) that will always be added to message. You may
also specify sender name in addition to email address using format: |
| $to | string|string[]|null |
The receiver email address(es). You may also specify sender name in addition
to email address using format: |
| $addTo | string|string[]|null |
The receiver email address(es) that will always be added to message. You may
also specify sender name in addition to email address using format: |
| $replyTo | string|string[]|null |
The reply-to address(es) of this message. You may also specify sender name
in addition to email address using format: |
| $addReplyTo | string|string[]|null |
The reply-to address(es) that will always be added to message. You may
also specify sender name in addition to email address using format: |
| $cc | string|string[]|null |
The additional copy receiver address(es) of this message. You may also specify
sender name in addition to email address using format: |
| $addCc | string|string[]|null |
The additional copy receiver address(es) that will always be added to message.
You may also specify sender name in addition to email address using format: |
| $bcc | string|string[]|null |
The hidden copy receiver address(es) of this message. You may also specify
sender name in addition to email address using format: |
| $addBcc | string|string[]|null |
The hidden copy receiver address(es) that will always be added to message.
You may also specify sender name in addition to email address using format: |
| $subject | string|null | |
| $date | DateTimeImmutable|null | |
| $priority | \Yiisoft\Mailer\Priority|null | |
| $returnPath | string|null | |
| $sender | string|null | |
| $textBody | string|null | |
| $htmlBody | string|null | |
| $attachments | Yiisoft\Mailer\File[]|null |
The attached files. |
| $addAttachments | Yiisoft\Mailer\File[]|null |
The attached files that will always be added to message. |
| $embeddings | Yiisoft\Mailer\File[]|null |
The embedded files. |
| $addEmbeddings | Yiisoft\Mailer\File[]|null |
The embedded files that will always be added to message. |
| $headers | array[]|null |
The custom headers in format |
| $overwriteHeaders | array[]|null |
The custom headers in format |
| $htmlToTextBodyConverter | callable|null |
The HTML to text body converter. |
public function __construct(
public readonly string|null $charset = null,
public readonly array|string|null $from = null,
public readonly array|string|null $addFrom = null,
public readonly array|string|null $to = null,
public readonly array|string|null $addTo = null,
public readonly array|string|null $replyTo = null,
public readonly array|string|null $addReplyTo = null,
public readonly array|string|null $cc = null,
public readonly array|string|null $addCc = null,
public readonly array|string|null $bcc = null,
public readonly array|string|null $addBcc = null,
public readonly string|null $subject = null,
public readonly DateTimeImmutable|null $date = null,
public readonly Priority|null $priority = null,
public readonly string|null $returnPath = null,
public readonly string|null $sender = null,
public readonly string|null $textBody = null,
public readonly string|null $htmlBody = null,
public readonly array|null $attachments = null,
public readonly array|null $addAttachments = null,
public readonly array|null $embeddings = null,
public readonly array|null $addEmbeddings = null,
array|null $headers = null,
array|null $overwriteHeaders = null,
callable|null $htmlToTextBodyConverter = null,
) {
$this->headers = HeadersNormalizer::normalize($headers);
$this->overwriteHeaders = HeadersNormalizer::normalize($overwriteHeaders);
$this->htmlToTextBodyConverter = $htmlToTextBodyConverter;
}
| public Yiisoft\Mailer\MessageInterface applyTo ( Yiisoft\Mailer\MessageInterface $message ) | ||
| $message | Yiisoft\Mailer\MessageInterface | |
public function applyTo(MessageInterface $message): MessageInterface
{
if ($this->charset !== null && $message->getCharset() === null) {
$message = $message->withCharset($this->charset);
}
if ($this->from !== null && $message->getFrom() === null) {
$message = $message->withFrom($this->from);
}
if ($this->addFrom !== null) {
$message = $message->withAddedFrom($this->addFrom);
}
if ($this->to !== null && $message->getTo() === null) {
$message = $message->withTo($this->to);
}
if ($this->addTo !== null) {
$message = $message->withAddedTo($this->addTo);
}
if ($this->replyTo !== null && $message->getReplyTo() === null) {
$message = $message->withReplyTo($this->replyTo);
}
if ($this->addReplyTo !== null) {
$message = $message->withAddedReplyTo($this->addReplyTo);
}
if ($this->cc !== null && $message->getCc() === null) {
$message = $message->withCc($this->cc);
}
if ($this->addCc !== null) {
$message = $message->withAddedCc($this->addCc);
}
if ($this->bcc !== null && $message->getBcc() === null) {
$message = $message->withBcc($this->bcc);
}
if ($this->addBcc !== null) {
$message = $message->withAddedBcc($this->addBcc);
}
if ($this->subject !== null && $message->getSubject() === null) {
$message = $message->withSubject($this->subject);
}
if ($this->date !== null && $message->getDate() === null) {
$message = $message->withDate($this->date);
}
if ($this->priority !== null && $message->getPriority() === null) {
$message = $message->withPriority($this->priority);
}
if ($this->returnPath !== null && $message->getReturnPath() === null) {
$message = $message->withReturnPath($this->returnPath);
}
if ($this->sender !== null && $message->getSender() === null) {
$message = $message->withSender($this->sender);
}
if ($this->textBody !== null && $message->getTextBody() === null) {
$message = $message->withTextBody($this->textBody);
}
if ($this->htmlBody !== null && $message->getHtmlBody() === null) {
$message = $message->withHtmlBody($this->htmlBody);
}
if ($this->attachments !== null && $message->getAttachments() === null) {
$message = $message->withAttachments(...$this->attachments);
}
if ($this->addAttachments !== null) {
$message = $message->withAddedAttachments(...$this->addAttachments);
}
if ($this->embeddings !== null && $message->getEmbeddings() === null) {
$message = $message->withEmbeddings(...$this->embeddings);
}
if ($this->addEmbeddings !== null) {
$message = $message->withAddedEmbeddings(...$this->addEmbeddings);
}
if ($this->headers !== null) {
$message = $message->withHeaders(
array_merge($this->headers, $message->getHeaders() ?? [])
);
}
if ($this->overwriteHeaders !== null) {
foreach ($this->overwriteHeaders as $headerName => $headerValue) {
$message = $message->withHeader($headerName, $headerValue);
}
}
if ($this->htmlToTextBodyConverter !== null && $message->getTextBody() === null) {
$html = $message->getHtmlBody();
if ($html !== null) {
$message = $message->withTextBody(
($this->htmlToTextBodyConverter)($html)
);
}
}
return $message;
}
Signup or Login in order to comment.