Final Class Yiisoft\Mailer\Symfony\Mailer
| Inheritance | Yiisoft\ |
|---|
Mailer implements a mailer based on Symfony Mailer.
See also https://github.com/symfony/mailer.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| withEncryptor() | Returns a new instance with the specified encryptor. | Yiisoft\ |
| withSigner() | Returns a new instance with the specified signer. | Yiisoft\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| sendMessage() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $transport | \ |
|
| $messageSettings | ?\ |
|
| $eventDispatcher | ?\ |
|
public function __construct(
TransportInterface $transport,
?MessageSettings $messageSettings = null,
?EventDispatcherInterface $eventDispatcher = null,
) {
parent::__construct($messageSettings, $eventDispatcher);
$this->symfonyMailer = new SymfonyMailer($transport);
$this->emailFactory = new EmailFactory();
}
| protected sendMessage ( \ | ||
| $message | \ |
|
| throws | \ |
If sending failed. |
|---|---|---|
protected function sendMessage(MessageInterface $message): void
{
$email = $this->emailFactory->create($message);
if ($this->encryptor !== null) {
$email = $this->encryptor->encrypt($email);
}
if ($this->signer !== null) {
$email = $this->signer instanceof DkimSigner
? $this->signer->sign($email, $this->dkimSignerOptions)
: $this->signer->sign($email)
;
}
$this->symfonyMailer->send($email);
}
Returns a new instance with the specified encryptor.
See also https://symfony.com/doc/current/mailer.html#encrypting-messages.
| public self withEncryptor ( \ | ||
| $encryptor | \ |
The encryptor instance. |
public function withEncryptor(SMimeEncrypter $encryptor): self
{
$new = clone $this;
$new->encryptor = $encryptor;
return $new;
}
Returns a new instance with the specified signer.
See also https://symfony.com/doc/current/mailer.html#signing-messages.
| public self withSigner ( \ | ||
| $signer | \ |
The signer instance. |
| $options | array |
The options for DKIM signer {@see \ |
| throws | RuntimeException |
If the signer is not an instance of {@see \ |
|---|---|---|
public function withSigner(object $signer, array $options = []): self
{
$new = clone $this;
if ($signer instanceof DkimSigner) {
$new->signer = $signer;
$new->dkimSignerOptions = $options;
return $new;
}
if ($signer instanceof SMimeSigner) {
$new->signer = $signer;
return $new;
}
throw new RuntimeException(sprintf(
'The signer must be an instance of "%s" or "%s". The "%s" instance is received.',
DkimSigner::class,
SMimeSigner::class,
$signer::class,
));
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.