feat: send all cron reminders over mailjet

This commit is contained in:
fromme committed 2026-11-10 17:13:05 +01:00
1 parent 8b5b7584b1
commit 8898320e21
13 files changed
+27 -9

No files matched your search

+2 -1
View File
@@ -2,7 +2,8 @@ framework:
mailer: mailer:
# "main" has to stay first: it is the transport every mail without an explicit # "main" has to stay first: it is the transport every mail without an explicit
# X-Transport header goes out over, which is all of them apart from the teamer # X-Transport header goes out over, which is all of them apart from the teamer
# mailing. Reordering this quietly moves the whole application to Mailjet. # mailing and the nightly cron reminders (App\Email\Mailer::MAILJET_TRANSPORT).
# Reordering this quietly moves the whole application to Mailjet.
transports: transports:
main: '%env(MAILER_DSN)%' main: '%env(MAILER_DSN)%'
mailing: '%env(MAILING_MAILER_DSN)%' mailing: '%env(MAILING_MAILER_DSN)%'
+2 -1
View File
@@ -121,7 +121,8 @@ Three failure modes worth knowing because they are quiet rather than loud:
- **`.env.local` missing from the deploy path.** `APP_ENV` falls back to `dev` and - **`.env.local` missing from the deploy path.** `APP_ENV` falls back to `dev` and
`MAILING_MAILER_DSN` to `null://null`. The worker then consumes every message and `MAILING_MAILER_DSN` to `null://null`. The worker then consumes every message and
delivers nothing, reporting success and recording no failure. The quietest failure in the delivers nothing, reporting success and recording no failure - mailings and the nightly
cron reminders alike, which both go out over Mailjet. The quietest failure in the
whole system. whole system.
- **No worker consuming `mailing`.** Mailings queue up indefinitely while the admin is told - **No worker consuming `mailing`.** Mailings queue up indefinitely while the admin is told
they are on their way. `messenger:stats` shows it immediately. they are on their way. `messenger:stats` shows it immediately.
@@ -23,8 +23,8 @@ use Psr\Log\LoggerInterface;
* is called inside the visitor's own form submission on another website. A delivery * is called inside the visitor's own form submission on another website. A delivery
* confirmation would need machinery nothing else here has. * confirmation would need machinery nothing else here has.
* *
* Goes over MAILER_DSN like every transactional mail; MAILING_MAILER_DSN is for the bulk teamer * Goes over MAILER_DSN like every transactional mail; MAILING_MAILER_DSN is for mail sent in
* mailing only. * volume, the teamer mailing and the cron reminders (Mailer::MAILJET_TRANSPORT).
*/ */
class ApplicationFormSubmissionMailer class ApplicationFormSubmissionMailer
{ {
+8
View File
@@ -14,6 +14,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
class Mailer class Mailer
{ {
/**
* The mailer transport for mail sent in volume - the teamer mailing and the nightly cron
* reminders: Mailjet (MAILING_MAILER_DSN, mailer.yaml), rather than the webhoster's relay that
* carries every other mail, which would risk the hosting account at a few hundred mails. Pass
* it as the 'transport' option.
*/
public const string MAILJET_TRANSPORT = 'mailing';
public function __construct( public function __construct(
private readonly MailerInterface $mailer, private readonly MailerInterface $mailer,
private readonly BodyRendererInterface $bodyRenderer, private readonly BodyRendererInterface $bodyRenderer,
@@ -75,7 +75,7 @@ class DispositionReminderService
$this->mailer->createAndSendText( $this->mailer->createAndSendText(
EmailTextKey::REMINDER_DISPOSITION, EmailTextKey::REMINDER_DISPOSITION,
$this->placeholderFactory->forDispositionReminder($disposition, self::REMINDER_LEAD_DAYS), $this->placeholderFactory->forDispositionReminder($disposition, self::REMINDER_LEAD_DAYS),
['to' => $teamer->getCommunication()->getEmail()], ['to' => $teamer->getCommunication()->getEmail(), 'transport' => Mailer::MAILJET_TRANSPORT],
); );
} }
@@ -81,6 +81,7 @@ class FeedbackReminderService
'to' => $manager->getEmail(), 'to' => $manager->getEmail(),
'subject' => 'Reminder: Offene Feedbacks', 'subject' => 'Reminder: Offene Feedbacks',
'template' => 'email/reminder_pending_feedback.html.twig', 'template' => 'email/reminder_pending_feedback.html.twig',
'transport' => Mailer::MAILJET_TRANSPORT,
]); ]);
} }
@@ -65,6 +65,7 @@ class QuestionnaireReminderService
)), )),
], [ ], [
'to' => $email, 'to' => $email,
'transport' => Mailer::MAILJET_TRANSPORT,
]); ]);
++$count; ++$count;
@@ -77,6 +77,7 @@ class SeasonTaskReminderService
], [ ], [
'subject' => 'Fristen für Saisonunterlagen erreicht', 'subject' => 'Fristen für Saisonunterlagen erreicht',
'template' => 'email/season_deadlines.html.twig', 'template' => 'email/season_deadlines.html.twig',
'transport' => Mailer::MAILJET_TRANSPORT,
]); ]);
$message = 'Sent the season task deadline summary for '.$count.' teamers'; $message = 'Sent the season task deadline summary for '.$count.' teamers';
@@ -146,6 +147,7 @@ class SeasonTaskReminderService
'tasks' => implode(', ', $entry['labels']), 'tasks' => implode(', ', $entry['labels']),
], [ ], [
'to' => $email, 'to' => $email,
'transport' => Mailer::MAILJET_TRANSPORT,
]); ]);
++$count; ++$count;
@@ -107,6 +107,7 @@ class UploadReminderService
{ {
$this->mailer->createAndSendText($key, $placeholders, [ $this->mailer->createAndSendText($key, $placeholders, [
'to' => $disposition->getTeamer()->getCommunication()->getEmail(), 'to' => $disposition->getTeamer()->getCommunication()->getEmail(),
'transport' => Mailer::MAILJET_TRANSPORT,
]); ]);
} }
} }
@@ -62,6 +62,7 @@ class WorkMonthReminderService
'workMonth' => $workMonth->getPeriodLabel(), 'workMonth' => $workMonth->getPeriodLabel(),
], [ ], [
'to' => $email, 'to' => $email,
'transport' => Mailer::MAILJET_TRANSPORT,
]); ]);
++$count; ++$count;
+2 -3
View File
@@ -30,10 +30,9 @@ class TeamerMailingService
/** /**
* The mailer transport a mailing goes out over: Mailjet, rather than the webhoster's * The mailer transport a mailing goes out over: Mailjet, rather than the webhoster's
* relay that carries every other mail, which would risk the hosting account over a few * relay, see Mailer::MAILJET_TRANSPORT.
* hundred recipients. Configured in mailer.yaml.
*/ */
private const TRANSPORT = 'mailing'; private const TRANSPORT = Mailer::MAILJET_TRANSPORT;
public function __construct( public function __construct(
private readonly TeamerRepository $teamerRepository, private readonly TeamerRepository $teamerRepository,
@@ -67,6 +67,8 @@ class QuestionnaireReminderServiceTest extends TestCase
->method('createAndSendText') ->method('createAndSendText')
->willReturnCallback(function (EmailTextKey $key, array $placeholders, array $options) use (&$sent): void { ->willReturnCallback(function (EmailTextKey $key, array $placeholders, array $options) use (&$sent): void {
$this->assertSame(EmailTextKey::REMINDER_QUESTIONNAIRE, $key); $this->assertSame(EmailTextKey::REMINDER_QUESTIONNAIRE, $key);
// over Mailjet, like every cron reminder
$this->assertSame(Mailer::MAILJET_TRANSPORT, $options['transport']);
$sent[$options['to']] = $placeholders['destinations']; $sent[$options['to']] = $placeholders['destinations'];
}) })
; ;
@@ -153,7 +153,8 @@ class UploadReminderServiceTest extends TestCase
EmailTextKey::REMINDER_INVOICE_UPLOAD, EmailTextKey::REMINDER_INVOICE_UPLOAD,
$this->callback(fn (array $placeholders): bool => self::INVOICE_DEADLINE_DAYS === $placeholders['invoiceUploadDeadlineDays'] $this->callback(fn (array $placeholders): bool => self::INVOICE_DEADLINE_DAYS === $placeholders['invoiceUploadDeadlineDays']
&& 'Skireise' === substr((string) $placeholders['destination'], -8)), && 'Skireise' === substr((string) $placeholders['destination'], -8)),
['to' => '[email protected]'], // over Mailjet, like every cron reminder (Mailer::MAILJET_TRANSPORT)
['to' => '[email protected]', 'transport' => Mailer::MAILJET_TRANSPORT],
) )
; ;