Final Class Yiisoft\Mailer\SwiftMailer\Message
| Inheritance | Yiisoft\Mailer\SwiftMailer\Message |
|---|---|
| Implements | Yiisoft\Mailer\MessageInterface |
Message implements a message class based on SwiftMailer.
See also:
Public Methods
Method Details
| public mixed __clone ( ) |
public function __clone()
{
$this->swiftMessage = clone $this->swiftMessage;
}
| public mixed __construct ( ) |
public function __construct()
{
$this->swiftMessage = new Swift_Message();
}
| public string __toString ( ) |
public function __toString(): string
{
return $this->swiftMessage->toString();
}
| public mixed getBcc ( ) |
public function getBcc()
{
return $this->normalizeAddresses($this->swiftMessage->getBcc());
}
| public mixed getCc ( ) |
public function getCc()
{
return $this->normalizeAddresses($this->swiftMessage->getCc());
}
| public string getCharset ( ) |
public function getCharset(): string
{
return $this->swiftMessage->getCharset();
}
| public DateTimeImmutable|null getDate ( ) |
public function getDate(): ?DateTimeImmutable
{
return $this->date;
}
| public mixed getFrom ( ) |
public function getFrom()
{
return $this->normalizeAddresses($this->swiftMessage->getFrom());
}
| 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;
}
| public string getHtmlBody ( ) |
public function getHtmlBody(): string
{
/** @psalm-suppress RedundantCastGivenDocblockType */
return (string) $this->swiftMessage->getBody();
}
| public integer getPriority ( ) |
public function getPriority(): int
{
/** @psalm-suppress RedundantCastGivenDocblockType */
return (int) $this->swiftMessage->getPriority();
}
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());
}
| public mixed getReplyTo ( ) |
public function getReplyTo()
{
return $this->normalizeAddresses($this->swiftMessage->getReplyTo());
}
| public string getReturnPath ( ) |
public function getReturnPath(): string
{
/** @psalm-suppress RedundantCastGivenDocblockType */
return (string) $this->swiftMessage->getReturnPath();
}
| 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);
}
| public string getSubject ( ) |
public function getSubject(): string
{
/** @psalm-suppress RedundantCastGivenDocblockType */
return (string) $this->swiftMessage->getSubject();
}
Returns a Swift message instance.
| public \Swift_Message getSwiftMessage ( ) | ||
| return | \Swift_Message |
Swift message instance. |
|---|---|---|
public function getSwiftMessage(): Swift_Message
{
return $this->swiftMessage;
}
| public string getTextBody ( ) |
public function getTextBody(): string
{
/** @psalm-suppress RedundantCastGivenDocblockType */
return (string) $this->swiftMessage->getBody();
}
| public mixed getTo ( ) |
public function getTo()
{
return $this->normalizeAddresses($this->swiftMessage->getTo());
}
| 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;
}
| 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;
}
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;
}
| public self withBcc ( mixed $bcc ) | ||
| $bcc | mixed | |
public function withBcc($bcc): self
{
$new = clone $this;
$new->swiftMessage->setBcc($bcc);
return $new;
}
| public self withCc ( mixed $cc ) | ||
| $cc | mixed | |
public function withCc($cc): self
{
$new = clone $this;
$new->swiftMessage->setCc($cc);
return $new;
}
| public self withCharset ( string $charset ) | ||
| $charset | string | |
public function withCharset(string $charset): self
{
$new = clone $this;
$new->swiftMessage->setCharset($charset);
return $new;
}
| 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;
}
| 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;
}
| public self withError ( Throwable $e ) | ||
| $e | Throwable | |
public function withError(Throwable $e): self
{
$new = clone $this;
$new->error = $e;
return $new;
}
| public self withFrom ( mixed $from ) | ||
| $from | mixed | |
public function withFrom($from): self
{
$new = clone $this;
$new->swiftMessage->setFrom($from);
return $new;
}
| 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;
}
| 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;
}
| public self withHtmlBody ( string $html ) | ||
| $html | string | |
public function withHtmlBody(string $html): self
{
$new = clone $this;
$new->setBody($html, 'text/html');
return $new;
}
| public self withPriority ( integer $priority ) | ||
| $priority | integer | |
public function withPriority(int $priority): self
{
$new = clone $this;
$new->swiftMessage->setPriority($priority);
return $new;
}
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;
}
| public self withReplyTo ( mixed $replyTo ) | ||
| $replyTo | mixed | |
public function withReplyTo($replyTo): self
{
$new = clone $this;
$new->swiftMessage->setReplyTo($replyTo);
return $new;
}
| public self withReturnPath ( string $address ) | ||
| $address | string | |
public function withReturnPath(string $address): self
{
$new = clone $this;
$new->swiftMessage->setReturnPath($address);
return $new;
}
| public self withSender ( string $address ) | ||
| $address | string | |
public function withSender(string $address): self
{
$new = clone $this;
$new->swiftMessage->setSender($address);
return $new;
}
| public self withSubject ( string $subject ) | ||
| $subject | string | |
public function withSubject(string $subject): self
{
$new = clone $this;
$new->swiftMessage->setSubject($subject);
return $new;
}
| public self withTextBody ( string $text ) | ||
| $text | string | |
public function withTextBody(string $text): self
{
$new = clone $this;
$new->setBody($text, 'text/plain');
return $new;
}
Signup or Login in order to comment.