0 follower

Final Class Yiisoft\Mailer\SwiftMailer\Message

InheritanceYiisoft\Mailer\SwiftMailer\Message
ImplementsYiisoft\Mailer\MessageInterface

Message implements a message class based on SwiftMailer.

See also:

Public Methods

Hide inherited methods

Method Description Defined By
__clone() Yiisoft\Mailer\SwiftMailer\Message
__construct() Yiisoft\Mailer\SwiftMailer\Message
__toString() Yiisoft\Mailer\SwiftMailer\Message
getBcc() Yiisoft\Mailer\SwiftMailer\Message
getCc() Yiisoft\Mailer\SwiftMailer\Message
getCharset() Yiisoft\Mailer\SwiftMailer\Message
getDate() Yiisoft\Mailer\SwiftMailer\Message
getError() Yiisoft\Mailer\SwiftMailer\Message
getFrom() Yiisoft\Mailer\SwiftMailer\Message
getHeader() Yiisoft\Mailer\SwiftMailer\Message
getHtmlBody() Yiisoft\Mailer\SwiftMailer\Message
getPriority() Yiisoft\Mailer\SwiftMailer\Message
getReadReceiptTo() Returns the addresses to which a read-receipt will be sent. Yiisoft\Mailer\SwiftMailer\Message
getReplyTo() Yiisoft\Mailer\SwiftMailer\Message
getReturnPath() Yiisoft\Mailer\SwiftMailer\Message
getSender() Yiisoft\Mailer\SwiftMailer\Message
getSubject() Yiisoft\Mailer\SwiftMailer\Message
getSwiftMessage() Returns a Swift message instance. Yiisoft\Mailer\SwiftMailer\Message
getTextBody() Yiisoft\Mailer\SwiftMailer\Message
getTo() Yiisoft\Mailer\SwiftMailer\Message
withAddedHeader() Yiisoft\Mailer\SwiftMailer\Message
withAttached() Yiisoft\Mailer\SwiftMailer\Message
withAttachedSigners() Returns a new instance with the specified attached signers. Yiisoft\Mailer\SwiftMailer\Message
withBcc() Yiisoft\Mailer\SwiftMailer\Message
withCc() Yiisoft\Mailer\SwiftMailer\Message
withCharset() Yiisoft\Mailer\SwiftMailer\Message
withDate() Yiisoft\Mailer\SwiftMailer\Message
withEmbedded() Yiisoft\Mailer\SwiftMailer\Message
withError() Yiisoft\Mailer\SwiftMailer\Message
withFrom() Yiisoft\Mailer\SwiftMailer\Message
withHeader() Yiisoft\Mailer\SwiftMailer\Message
withHeaders() Yiisoft\Mailer\SwiftMailer\Message
withHtmlBody() Yiisoft\Mailer\SwiftMailer\Message
withPriority() Yiisoft\Mailer\SwiftMailer\Message
withReadReceiptTo() Returns a new instance with the specified ask for a delivery receipt from the recipient to be sent to addresses. Yiisoft\Mailer\SwiftMailer\Message
withReplyTo() Yiisoft\Mailer\SwiftMailer\Message
withReturnPath() Yiisoft\Mailer\SwiftMailer\Message
withSender() Yiisoft\Mailer\SwiftMailer\Message
withSubject() Yiisoft\Mailer\SwiftMailer\Message
withTextBody() Yiisoft\Mailer\SwiftMailer\Message
withTo() Yiisoft\Mailer\SwiftMailer\Message

Method Details

Hide inherited methods

__clone() public method

public mixed __clone ( )

                public function __clone()
{
    $this->swiftMessage = clone $this->swiftMessage;
}

            
__construct() public method

public mixed __construct ( )

                public function __construct()
{
    $this->swiftMessage = new Swift_Message();
}

            
__toString() public method

public string __toString ( )

                public function __toString(): string
{
    return $this->swiftMessage->toString();
}

            
getBcc() public method

public mixed getBcc ( )

                public function getBcc()
{
    return $this->normalizeAddresses($this->swiftMessage->getBcc());
}

            
getCc() public method

public mixed getCc ( )

                public function getCc()
{
    return $this->normalizeAddresses($this->swiftMessage->getCc());
}

            
getCharset() public method

public string getCharset ( )

                public function getCharset(): string
{
    return $this->swiftMessage->getCharset();
}

            
getDate() public method

public DateTimeImmutable|null getDate ( )

                public function getDate(): ?DateTimeImmutable
{
    return $this->date;
}

            
getError() public method

public Throwable|null getError ( )

                public function getError(): ?Throwable
{
    return $this->error;
}

            
getFrom() public method

public mixed getFrom ( )

                public function getFrom()
{
    return $this->normalizeAddresses($this->swiftMessage->getFrom());
}

            
getHeader() public method

public array getHeader ( string $name )
$name string

                public function getHeader(string $name): array
{
    $headerSet = $this->swiftMessage->getHeaders();
    if (!$headerSet->has($name)) {
        return [];
    }
    $headers = [];
    /** @var Swift_Mime_Headers_UnstructuredHeader $header */
    foreach ($headerSet->getAll($name) as $header) {
        $headers[] = $header->getValue();
    }
    return $headers;
}

            
getHtmlBody() public method

public string getHtmlBody ( )

                public function getHtmlBody(): string
{
    /** @psalm-suppress RedundantCastGivenDocblockType */
    return (string) $this->swiftMessage->getBody();
}

            
getPriority() public method

public integer getPriority ( )

                public function getPriority(): int
{
    /** @psalm-suppress RedundantCastGivenDocblockType */
    return (int) $this->swiftMessage->getPriority();
}

            
getReadReceiptTo() public method

Returns the addresses to which a read-receipt will be sent.

public array<string, string>|string getReadReceiptTo ( )
return array<string, string>|string

The receipt receive email addresses.

                public function getReadReceiptTo()
{
    return $this->normalizeAddresses($this->swiftMessage->getReadReceiptTo());
}

            
getReplyTo() public method

public mixed getReplyTo ( )

                public function getReplyTo()
{
    return $this->normalizeAddresses($this->swiftMessage->getReplyTo());
}

            
getReturnPath() public method

public string getReturnPath ( )

                public function getReturnPath(): string
{
    /** @psalm-suppress RedundantCastGivenDocblockType */
    return (string) $this->swiftMessage->getReturnPath();
}

            
getSender() public method

public string getSender ( )

                public function getSender(): string
{
    /** @var array<string, null>|null $sender */
    $sender = $this->swiftMessage->getSender();
    /** @psalm-suppress RedundantCastGivenDocblockType */
    return empty($sender) ? '' : (string) array_key_first($sender);
}

            
getSubject() public method

public string getSubject ( )

                public function getSubject(): string
{
    /** @psalm-suppress RedundantCastGivenDocblockType */
    return (string) $this->swiftMessage->getSubject();
}

            
getSwiftMessage() public method

Returns a Swift message instance.

public \Swift_Message getSwiftMessage ( )
return \Swift_Message

Swift message instance.

                public function getSwiftMessage(): Swift_Message
{
    return $this->swiftMessage;
}

            
getTextBody() public method

public string getTextBody ( )

                public function getTextBody(): string
{
    /** @psalm-suppress RedundantCastGivenDocblockType */
    return (string) $this->swiftMessage->getBody();
}

            
getTo() public method

public mixed getTo ( )

                public function getTo()
{
    return $this->normalizeAddresses($this->swiftMessage->getTo());
}

            
withAddedHeader() public method

public self withAddedHeader ( string $name, string $value )
$name string
$value string

                public function withAddedHeader(string $name, string $value): self
{
    $new = clone $this;
    $new->swiftMessage
        ->getHeaders()
        ->addTextHeader($name, $value);
    return $new;
}

            
withAttached() public method

public self withAttached ( \Yiisoft\Mailer\File $file )
$file \Yiisoft\Mailer\File

                public function withAttached(File $file): self
{
    $attachment = $file->path() === null
        ? new Swift_Attachment($file->content())
        : Swift_Attachment::fromPath($file->path())
    ;
    if (!empty($file->name())) {
        $attachment->setFilename($file->name());
    }
    if (!empty($file->contentType())) {
        $attachment->setContentType($file->contentType());
    }
    $new = clone $this;
    $new->swiftMessage->attach($attachment);
    return $new;
}

            
withAttachedSigners() public method

Returns a new instance with the specified attached signers.

public self withAttachedSigners ( \Swift_Signer[] $signers )
$signers \Swift_Signer[]

                public function withAttachedSigners(array $signers): self
{
    $new = clone $this;
    foreach ($signers as $signer) {
        $new->swiftMessage->attachSigner($signer);
    }
    return $new;
}

            
withBcc() public method

public self withBcc ( mixed $bcc )
$bcc mixed

                public function withBcc($bcc): self
{
    $new = clone $this;
    $new->swiftMessage->setBcc($bcc);
    return $new;
}

            
withCc() public method

public self withCc ( mixed $cc )
$cc mixed

                public function withCc($cc): self
{
    $new = clone $this;
    $new->swiftMessage->setCc($cc);
    return $new;
}

            
withCharset() public method

public self withCharset ( string $charset )
$charset string

                public function withCharset(string $charset): self
{
    $new = clone $this;
    $new->swiftMessage->setCharset($charset);
    return $new;
}

            
withDate() public method

public self withDate ( DateTimeInterface $date )
$date DateTimeInterface

                public function withDate(DateTimeInterface $date): self
{
    if ($date instanceof DateTime) {
        $immutable = new DateTimeImmutable('@' . $date->getTimestamp());
        $date = $immutable->setTimezone($date->getTimezone());
    }
    $new = $this->withHeader('Date', $date->format(DateTimeInterface::RFC2822));
    $new->date = $date;
    return $new;
}

            
withEmbedded() public method

public self withEmbedded ( \Yiisoft\Mailer\File $file )
$file \Yiisoft\Mailer\File

                public function withEmbedded(File $file): self
{
    $embedFile = $file->path() === null
        ? new Swift_EmbeddedFile($file->content())
        : Swift_EmbeddedFile::fromPath($file->path())
    ;
    if (!empty($file->name())) {
        $embedFile->setFilename($file->name());
    }
    if (!empty($file->contentType())) {
        $embedFile->setContentType($file->contentType());
    }
    $new = clone $this;
    $new->swiftMessage->embed($embedFile->setId($file->id()));
    return $new;
}

            
withError() public method

public self withError ( Throwable $e )
$e Throwable

                public function withError(Throwable $e): self
{
    $new = clone $this;
    $new->error = $e;
    return $new;
}

            
withFrom() public method

public self withFrom ( mixed $from )
$from mixed

                public function withFrom($from): self
{
    $new = clone $this;
    $new->swiftMessage->setFrom($from);
    return $new;
}

            
withHeader() public method

public self withHeader ( string $name, mixed $value )
$name string
$value mixed

                public function withHeader(string $name, $value): self
{
    $new = clone $this;
    $headerSet = $new->swiftMessage->getHeaders();
    if ($headerSet->has($name)) {
        $headerSet->remove($name);
    }
    foreach ((array) $value as $v) {
        $headerSet->addTextHeader($name, $v);
    }
    return $new;
}

            
withHeaders() public method

public self withHeaders ( array $headers )
$headers array

                public function withHeaders(array $headers): self
{
    $new = clone $this;
    foreach ($headers as $name => $value) {
        $new = $new->withHeader($name, $value);
    }
    return $new;
}

            
withHtmlBody() public method

public self withHtmlBody ( string $html )
$html string

                public function withHtmlBody(string $html): self
{
    $new = clone $this;
    $new->setBody($html, 'text/html');
    return $new;
}

            
withPriority() public method

public self withPriority ( integer $priority )
$priority integer

                public function withPriority(int $priority): self
{
    $new = clone $this;
    $new->swiftMessage->setPriority($priority);
    return $new;
}

            
withReadReceiptTo() public method

Returns a new instance with the specified ask for a delivery receipt from the recipient to be sent to addresses.

public self withReadReceiptTo ( string|string[] $addresses )
$addresses string|string[]

The receipt receive email address(es).

                public function withReadReceiptTo($addresses): self
{
    $new = clone $this;
    $new->swiftMessage->setReadReceiptTo((array) $addresses);
    return $new;
}

            
withReplyTo() public method

public self withReplyTo ( mixed $replyTo )
$replyTo mixed

                public function withReplyTo($replyTo): self
{
    $new = clone $this;
    $new->swiftMessage->setReplyTo($replyTo);
    return $new;
}

            
withReturnPath() public method

public self withReturnPath ( string $address )
$address string

                public function withReturnPath(string $address): self
{
    $new = clone $this;
    $new->swiftMessage->setReturnPath($address);
    return $new;
}

            
withSender() public method

public self withSender ( string $address )
$address string

                public function withSender(string $address): self
{
    $new = clone $this;
    $new->swiftMessage->setSender($address);
    return $new;
}

            
withSubject() public method

public self withSubject ( string $subject )
$subject string

                public function withSubject(string $subject): self
{
    $new = clone $this;
    $new->swiftMessage->setSubject($subject);
    return $new;
}

            
withTextBody() public method

public self withTextBody ( string $text )
$text string

                public function withTextBody(string $text): self
{
    $new = clone $this;
    $new->setBody($text, 'text/plain');
    return $new;
}

            
withTo() public method

public self withTo ( mixed $to )
$to mixed

                public function withTo($to): self
{
    $new = clone $this;
    $new->swiftMessage->setTo($to);
    return $new;
}