feat: send emails async via messenger

This commit is contained in:
Björn Fromme
2025-01-23 09:38:30 +01:00
parent 81a34d73c2
commit 3b6ef6e364
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ framework:
sync: 'sync://' sync: 'sync://'
routing: routing:
Symfony\Component\Mailer\Messenger\SendEmailMessage: sync Symfony\Component\Mailer\Messenger\SendEmailMessage: async
Symfony\Component\Notifier\Message\ChatMessage: async Symfony\Component\Notifier\Message\ChatMessage: async
Symfony\Component\Notifier\Message\SmsMessage: async Symfony\Component\Notifier\Message\SmsMessage: async
+4
View File
@@ -8,6 +8,7 @@ use Symfony\Bridge\Twig\Mime\TemplatedEmail;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface; use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Address; use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\BodyRendererInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface;
@@ -15,6 +16,7 @@ class Mailer
{ {
public function __construct( public function __construct(
private readonly MailerInterface $mailer, private readonly MailerInterface $mailer,
private readonly BodyRendererInterface $bodyRenderer,
private readonly TranslatorInterface $translator, private readonly TranslatorInterface $translator,
private readonly array $defaults, private readonly array $defaults,
private readonly LoggerInterface $logger private readonly LoggerInterface $logger
@@ -48,6 +50,8 @@ class Mailer
$email->attach($attachment->getContent(), $attachment->getName(), $attachment->getMimeType()); $email->attach($attachment->getContent(), $attachment->getName(), $attachment->getMimeType());
} }
$this->bodyRenderer->render($email);
return $email; return $email;
} }