From 2a93f1fdf404cf0b85a6e7ad16f35b522261d192 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Wed, 8 May 2024 13:30:05 +0200 Subject: [PATCH] Fall back to ##admin_email## automatically if not defined otherwise as it used to be in v1 --- src/Gateway/MailerGateway.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Gateway/MailerGateway.php b/src/Gateway/MailerGateway.php index b115fa4..5a81275 100644 --- a/src/Gateway/MailerGateway.php +++ b/src/Gateway/MailerGateway.php @@ -95,7 +95,12 @@ private function createEmailStamp(Parcel $parcel): EmailStamp $stamp = $stamp->withTo($this->replaceTokensAndInsertTags($parcel, $languageConfig->getString('recipients'))); $stamp = $stamp->withSubject($this->replaceTokensAndInsertTags($parcel, $languageConfig->getString('email_subject'))); - if ('' !== ($from = $this->replaceTokensAndInsertTags($parcel, $languageConfig->getString('email_sender_address')))) { + // Automatically fall back to ##admin_email## if no sender was configured. In + // case this token does not exist either, it will result in the same error as not + // supplying a sender address at all. + $from = '' !== $languageConfig->getString('email_sender_address') ? $languageConfig->getString('email_sender_address') : '##admin_email##'; + + if ('' !== ($from = $this->replaceTokensAndInsertTags($parcel, $from))) { $stamp = $stamp->withFrom($from); }