feat: use dedicated sender for accommodation related emails
This commit is contained in:
@@ -84,7 +84,7 @@ APP_TRAVEL_SNAPSHOT_RETENTION_BUFFER_DAYS=14
|
|||||||
# Emails
|
# Emails
|
||||||
APP_DEFAULT_EMAIL_FROM=[email protected]
|
APP_DEFAULT_EMAIL_FROM=[email protected]
|
||||||
APP_DEFAULT_EMAIL_TO=[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
|
# Global common defaults
|
||||||
APP_SEASON_WINTER_FROM=2026-10-01
|
APP_SEASON_WINTER_FROM=2026-10-01
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ services:
|
|||||||
|
|
||||||
App\Service\AccommodationBookingService:
|
App\Service\AccommodationBookingService:
|
||||||
arguments:
|
arguments:
|
||||||
$officeEmail: '%accommodation_inquiry_email%'
|
$accommodationEmail: '%accommodation_inquiry_email%'
|
||||||
|
|
||||||
App\Service\GroupsPriceCalculator:
|
App\Service\GroupsPriceCalculator:
|
||||||
arguments:
|
arguments:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class AccommodationBookingService
|
|||||||
private readonly CmsDataProvider $cmsDataProvider,
|
private readonly CmsDataProvider $cmsDataProvider,
|
||||||
private readonly AccommodationBookingLinkSigner $linkSigner,
|
private readonly AccommodationBookingLinkSigner $linkSigner,
|
||||||
private readonly AccommodationBookingBreakdownCalculator $breakdownCalculator,
|
private readonly AccommodationBookingBreakdownCalculator $breakdownCalculator,
|
||||||
private readonly string $officeEmail,
|
private readonly string $accommodationEmail,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,6 +369,30 @@ class AccommodationBookingService
|
|||||||
|
|
||||||
public function sendNotificationEmail(AccommodationBooking $booking): void
|
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 {
|
try {
|
||||||
$this->mailer->createAndSendEmail(
|
$this->mailer->createAndSendEmail(
|
||||||
[
|
[
|
||||||
@@ -376,18 +400,15 @@ class AccommodationBookingService
|
|||||||
'accessLink' => $this->accessLinkOrNull($booking),
|
'accessLink' => $this->accessLinkOrNull($booking),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'to' => $this->officeEmail,
|
'from' => $this->accommodationEmail,
|
||||||
'subject' => sprintf(
|
'to' => $to,
|
||||||
'Neue Unterkunfts%s: %s',
|
'subject' => $subject,
|
||||||
$booking->isInquiry() ? 'anfrage' : 'buchung',
|
'template' => $template,
|
||||||
$booking->getAccommodation()?->getName(),
|
|
||||||
),
|
|
||||||
'template' => 'email/accommodation_booking.html.twig',
|
|
||||||
'attachments' => [],
|
'attachments' => [],
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->logger->error('Failed to send accommodation booking notification email', [
|
$this->logger->error($errorMessage, [
|
||||||
'booking_id' => $booking->getId(),
|
'booking_id' => $booking->getId(),
|
||||||
'error' => $e->getMessage(),
|
'error' => $e->getMessage(),
|
||||||
]);
|
]);
|
||||||
@@ -415,27 +436,15 @@ class AccommodationBookingService
|
|||||||
*/
|
*/
|
||||||
public function sendCustomerConfirmationEmail(AccommodationBooking $booking): void
|
public function sendCustomerConfirmationEmail(AccommodationBooking $booking): void
|
||||||
{
|
{
|
||||||
try {
|
$this->sendBookingEmail(
|
||||||
$this->mailer->createAndSendEmail(
|
$booking,
|
||||||
[
|
$booking->getEmail(),
|
||||||
'booking' => $booking,
|
$booking->isInquiry()
|
||||||
'accessLink' => $this->accessLinkOrNull($booking),
|
? 'Deine Anfrage ist bei uns eingegangen'
|
||||||
],
|
: 'Deine Buchung ist bestätigt',
|
||||||
[
|
'email/accommodation_booking_customer.html.twig',
|
||||||
'to' => $booking->getEmail(),
|
'Failed to send accommodation booking customer confirmation email',
|
||||||
'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(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -469,48 +478,24 @@ class AccommodationBookingService
|
|||||||
|
|
||||||
public function sendOfferAcceptedNotificationEmail(AccommodationBooking $booking): void
|
public function sendOfferAcceptedNotificationEmail(AccommodationBooking $booking): void
|
||||||
{
|
{
|
||||||
try {
|
$this->sendBookingEmail(
|
||||||
$this->mailer->createAndSendEmail(
|
$booking,
|
||||||
[
|
$this->accommodationEmail,
|
||||||
'booking' => $booking,
|
sprintf('Angebot angenommen: %s', $booking->getAccommodation()?->getName()),
|
||||||
'accessLink' => $this->accessLinkOrNull($booking),
|
'email/offer_accepted.html.twig',
|
||||||
],
|
'Failed to send offer accepted notification email',
|
||||||
[
|
);
|
||||||
'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(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendOfferAcceptedCustomerEmail(AccommodationBooking $booking): void
|
public function sendOfferAcceptedCustomerEmail(AccommodationBooking $booking): void
|
||||||
{
|
{
|
||||||
try {
|
$this->sendBookingEmail(
|
||||||
$this->mailer->createAndSendEmail(
|
$booking,
|
||||||
[
|
$booking->getEmail(),
|
||||||
'booking' => $booking,
|
'Deine Buchung ist bestätigt',
|
||||||
'accessLink' => $this->accessLinkOrNull($booking),
|
'email/offer_accepted_customer.html.twig',
|
||||||
],
|
'Failed to send offer accepted customer email',
|
||||||
[
|
);
|
||||||
'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(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function accessLinkOrNull(AccommodationBooking $booking): ?string
|
private function accessLinkOrNull(AccommodationBooking $booking): ?string
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
->with(
|
->with(
|
||||||
self::callback(static fn (array $context) => 'https://example.com/offer/signed-link' === $context['accessLink']),
|
self::callback(static fn (array $context) => 'https://example.com/offer/signed-link' === $context['accessLink']),
|
||||||
self::callback(static fn (array $options) => '[email protected]' === $options['to']
|
self::callback(static fn (array $options) => '[email protected]' === $options['to']
|
||||||
|
&& '[email protected]' === $options['from']
|
||||||
&& 'email/accommodation_booking_customer.html.twig' === $options['template']),
|
&& 'email/accommodation_booking_customer.html.twig' === $options['template']),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -219,6 +220,7 @@ class AccommodationBookingServiceTest extends TestCase
|
|||||||
->with(
|
->with(
|
||||||
self::anything(),
|
self::anything(),
|
||||||
self::callback(static fn (array $options) => in_array($options['to'], ['[email protected]', '[email protected]'], true)
|
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)),
|
&& in_array($options['template'], ['email/offer_accepted.html.twig', 'email/offer_accepted_customer.html.twig'], true)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user