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:
# "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
# 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:
main: '%env(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
`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.
- **No worker consuming `mailing`.** Mailings queue up indefinitely while the admin is told
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
* confirmation would need machinery nothing else here has.
*
* Goes over MAILER_DSN like every transactional mail; MAILING_MAILER_DSN is for the bulk teamer
* mailing only.
* Goes over MAILER_DSN like every transactional mail; MAILING_MAILER_DSN is for mail sent in
* volume, the teamer mailing and the cron reminders (Mailer::MAILJET_TRANSPORT).
*/
class ApplicationFormSubmissionMailer
{
+8
View File
@@ -14,6 +14,14 @@ use Symfony\Contracts\Translation\TranslatorInterface;
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(
private readonly MailerInterface $mailer,
private readonly BodyRendererInterface $bodyRenderer,
@@ -75,7 +75,7 @@ class DispositionReminderService
$this->mailer->createAndSendText(
EmailTextKey::REMINDER_DISPOSITION,
$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(),
'subject' => 'Reminder: Offene Feedbacks',
'template' => 'email/reminder_pending_feedback.html.twig',
'transport' => Mailer::MAILJET_TRANSPORT,
]);
}
@@ -65,6 +65,7 @@ class QuestionnaireReminderService
)),
], [
'to' => $email,
'transport' => Mailer::MAILJET_TRANSPORT,
]);
++$count;
@@ -77,6 +77,7 @@ class SeasonTaskReminderService
], [
'subject' => 'Fristen für Saisonunterlagen erreicht',
'template' => 'email/season_deadlines.html.twig',
'transport' => Mailer::MAILJET_TRANSPORT,
]);
$message = 'Sent the season task deadline summary for '.$count.' teamers';
@@ -146,6 +147,7 @@ class SeasonTaskReminderService
'tasks' => implode(', ', $entry['labels']),
], [
'to' => $email,
'transport' => Mailer::MAILJET_TRANSPORT,
]);
++$count;
@@ -107,6 +107,7 @@ class UploadReminderService
{
$this->mailer->createAndSendText($key, $placeholders, [
'to' => $disposition->getTeamer()->getCommunication()->getEmail(),
'transport' => Mailer::MAILJET_TRANSPORT,
]);
}
}
@@ -62,6 +62,7 @@ class WorkMonthReminderService
'workMonth' => $workMonth->getPeriodLabel(),
], [
'to' => $email,
'transport' => Mailer::MAILJET_TRANSPORT,
]);
++$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
* relay that carries every other mail, which would risk the hosting account over a few
* hundred recipients. Configured in mailer.yaml.
* relay, see Mailer::MAILJET_TRANSPORT.
*/
private const TRANSPORT = 'mailing';
private const TRANSPORT = Mailer::MAILJET_TRANSPORT;
public function __construct(
private readonly TeamerRepository $teamerRepository,
@@ -67,6 +67,8 @@ class QuestionnaireReminderServiceTest extends TestCase
->method('createAndSendText')
->willReturnCallback(function (EmailTextKey $key, array $placeholders, array $options) use (&$sent): void {
$this->assertSame(EmailTextKey::REMINDER_QUESTIONNAIRE, $key);
// over Mailjet, like every cron reminder
$this->assertSame(Mailer::MAILJET_TRANSPORT, $options['transport']);
$sent[$options['to']] = $placeholders['destinations'];
})
;
@@ -153,7 +153,8 @@ class UploadReminderServiceTest extends TestCase
EmailTextKey::REMINDER_INVOICE_UPLOAD,
$this->callback(fn (array $placeholders): bool => self::INVOICE_DEADLINE_DAYS === $placeholders['invoiceUploadDeadlineDays']
&& '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],
)
;