Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Classes/Service/MailerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Neos\Flow\Annotations as Flow;
use Neos\SymfonyMailer\Exception\InvalidMailerConfigurationException;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Mailer\Transport;
use Symfony\Component\Mailer\Mailer;
use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport;
Expand All @@ -33,21 +34,22 @@ class MailerService
* Returns a mailer instance with the given transport or the configured default transport.
*
* @param TransportInterface|null $transport
* @param EventDispatcherInterface|null $dispatcher
* @return Mailer
* @throws InvalidMailerConfigurationException
*/
public function getMailer(TransportInterface $transport = null): Mailer
public function getMailer(TransportInterface $transport = null, ?EventDispatcherInterface $dispatcher = null): Mailer
{
if ($transport !== null) {
return new Mailer($transport);
return new Mailer($transport, null, $dispatcher);
}

// throw exception when dsn is not set
if (!isset($this->mailerConfiguration['dsn'])) {
throw new InvalidMailerConfigurationException('No DSN configured for Neos.SymfonyMailer', 1739540476);
}

return new Mailer(Transport::fromDsn($this->mailerConfiguration['dsn']));
return new Mailer(Transport::fromDsn($this->mailerConfiguration['dsn'], $dispatcher), null, $dispatcher);
}

/**
Expand Down