feat: use dedicated sender for accommodation related emails

This commit is contained in:
Björn Fromme
2026-08-04 09:21:00 +02:00
parent 97d98f7f12
commit dde36ccba2
4 changed files with 57 additions and 70 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ APP_TRAVEL_SNAPSHOT_RETENTION_BUFFER_DAYS=14
# Emails
APP_DEFAULT_EMAIL_FROM=[email protected]
APP_DEFAULT_EMAIL_TO=[email protected]
ACCOMMODATION_INQUIRY_EMAIL=info@ep-reisen.de
ACCOMMODATION_INQUIRY_EMAIL=gruppen@ep-reisen.de
# Global common defaults
APP_SEASON_WINTER_FROM=2026-10-01
+1 -1
View File
@@ -265,7 +265,7 @@ services:
App\Service\AccommodationBookingService:
arguments:
$officeEmail: '%accommodation_inquiry_email%'
$accommodationEmail: '%accommodation_inquiry_email%'
App\Service\GroupsPriceCalculator:
arguments:
+53 -68
View File
@@ -37,7 +37,7 @@ class AccommodationBookingService
private readonly CmsDataProvider $cmsDataProvider,
private readonly AccommodationBookingLinkSigner $linkSigner,
private readonly AccommodationBookingBreakdownCalculator $breakdownCalculator,
private readonly string $officeEmail,
private readonly string $accommodationEmail,
) {
}
@@ -369,6 +369,30 @@ class AccommodationBookingService
public function sendNotificationEmail(AccommodationBooking $booking): void
{
$this->sendBookingEmail(
$booking,
$this->accommodationEmail,
sprintf(
'Neue Unterkunfts%s: %s',
$booking->isInquiry() ? 'anfrage' : 'buchung',
$booking->getAccommodation()?->getName(),
),
'email/accommodation_booking.html.twig',
'Failed to send accommodation booking notification email',
);
}
/**
* All accommodation mail is sent from the group desk address so customer replies
* land there rather than in the general inbox.
*/
private function sendBookingEmail(
AccommodationBooking $booking,
string $to,
string $subject,
string $template,
string $errorMessage,
): void {
try {
$this->mailer->createAndSendEmail(
[
@@ -376,18 +400,15 @@ class AccommodationBookingService
'accessLink' => $this->accessLinkOrNull($booking),
],
[
'to' => $this->officeEmail,
'subject' => sprintf(
'Neue Unterkunfts%s: %s',
$booking->isInquiry() ? 'anfrage' : 'buchung',
$booking->getAccommodation()?->getName(),
),
'template' => 'email/accommodation_booking.html.twig',
'from' => $this->accommodationEmail,
'to' => $to,
'subject' => $subject,
'template' => $template,
'attachments' => [],
],
);
} catch (\Throwable $e) {
$this->logger->error('Failed to send accommodation booking notification email', [
$this->logger->error($errorMessage, [
'booking_id' => $booking->getId(),
'error' => $e->getMessage(),
]);
@@ -415,27 +436,15 @@ class AccommodationBookingService
*/
public function sendCustomerConfirmationEmail(AccommodationBooking $booking): void
{
try {
$this->mailer->createAndSendEmail(
[
'booking' => $booking,
'accessLink' => $this->accessLinkOrNull($booking),
],
[
'to' => $booking->getEmail(),
'subject' => $booking->isInquiry()
? 'Deine Anfrage ist bei uns eingegangen'
: 'Deine Buchung ist bestätigt',
'template' => 'email/accommodation_booking_customer.html.twig',
'attachments' => [],
],
);
} catch (\Throwable $e) {
$this->logger->error('Failed to send accommodation booking customer confirmation email', [
'booking_id' => $booking->getId(),
'error' => $e->getMessage(),
]);
}
$this->sendBookingEmail(
$booking,
$booking->getEmail(),
$booking->isInquiry()
? 'Deine Anfrage ist bei uns eingegangen'
: 'Deine Buchung ist bestätigt',
'email/accommodation_booking_customer.html.twig',
'Failed to send accommodation booking customer confirmation email',
);
}
/**
@@ -469,48 +478,24 @@ class AccommodationBookingService
public function sendOfferAcceptedNotificationEmail(AccommodationBooking $booking): void
{
try {
$this->mailer->createAndSendEmail(
[
'booking' => $booking,
'accessLink' => $this->accessLinkOrNull($booking),
],
[
'to' => $this->officeEmail,
'subject' => sprintf('Angebot angenommen: %s', $booking->getAccommodation()?->getName()),
'template' => 'email/offer_accepted.html.twig',
'attachments' => [],
],
);
} catch (\Throwable $e) {
$this->logger->error('Failed to send offer accepted notification email', [
'booking_id' => $booking->getId(),
'error' => $e->getMessage(),
]);
}
$this->sendBookingEmail(
$booking,
$this->accommodationEmail,
sprintf('Angebot angenommen: %s', $booking->getAccommodation()?->getName()),
'email/offer_accepted.html.twig',
'Failed to send offer accepted notification email',
);
}
public function sendOfferAcceptedCustomerEmail(AccommodationBooking $booking): void
{
try {
$this->mailer->createAndSendEmail(
[
'booking' => $booking,
'accessLink' => $this->accessLinkOrNull($booking),
],
[
'to' => $booking->getEmail(),
'subject' => 'Deine Buchung ist bestätigt',
'template' => 'email/offer_accepted_customer.html.twig',
'attachments' => [],
],
);
} catch (\Throwable $e) {
$this->logger->error('Failed to send offer accepted customer email', [
'booking_id' => $booking->getId(),
'error' => $e->getMessage(),
]);
}
$this->sendBookingEmail(
$booking,
$booking->getEmail(),
'Deine Buchung ist bestätigt',
'email/offer_accepted_customer.html.twig',
'Failed to send offer accepted customer email',
);
}
private function accessLinkOrNull(AccommodationBooking $booking): ?string
@@ -124,6 +124,7 @@ class AccommodationBookingServiceTest extends TestCase
->with(
self::callback(static fn (array $context) => 'https://example.com/offer/signed-link' === $context['accessLink']),
self::callback(static fn (array $options) => '[email protected]' === $options['to']
&& '[email protected]' === $options['from']
&& 'email/accommodation_booking_customer.html.twig' === $options['template']),
);
@@ -219,6 +220,7 @@ class AccommodationBookingServiceTest extends TestCase
->with(
self::anything(),
self::callback(static fn (array $options) => in_array($options['to'], ['[email protected]', '[email protected]'], true)
&& '[email protected]' === $options['from']
&& in_array($options['template'], ['email/offer_accepted.html.twig', 'email/offer_accepted_customer.html.twig'], true)),
);