From 1aa876553e4dc3f7e3c3bd7fae9dbb557361a8ac Mon Sep 17 00:00:00 2001 From: Simon Krull Date: Wed, 7 Feb 2024 11:59:16 +0100 Subject: [PATCH] BUGFIX: make sure recipients is of type string --- Classes/Domain/Model/Mail.php | 4 ++-- Classes/Module/MailDev.php | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Classes/Domain/Model/Mail.php b/Classes/Domain/Model/Mail.php index c7a09fc..f8792bf 100644 --- a/Classes/Domain/Model/Mail.php +++ b/Classes/Domain/Model/Mail.php @@ -43,8 +43,8 @@ public function __construct(array $mailData) $this->mailData = $mailData; $this->body = Arrays::getValueByPath($this->mailData, 'html'); - $this->recipients = Arrays::getValueByPath($this->mailData, 'headers.To'); - $this->subject = Arrays::getValueByPath($this->mailData, 'headers.Subject'); + $this->recipients = Arrays::getValueByPath($this->mailData, 'headers.to'); + $this->subject = Arrays::getValueByPath($this->mailData, 'headers.subject'); } diff --git a/Classes/Module/MailDev.php b/Classes/Module/MailDev.php index cbbd4df..941021d 100644 --- a/Classes/Module/MailDev.php +++ b/Classes/Module/MailDev.php @@ -100,10 +100,18 @@ public function seeTextInMail(string $text): void public function checkRecipientAddress(string $address): void { $recipients = $this->currentMail->getRecipients(); - foreach ($recipients as $recipient) { - if ($recipient === $address) { + if (is_string($recipients)) { + if ($recipients === $address) { return; } + } elseif (is_array($recipients)) { + foreach ($recipients as $recipient) { + if ($recipient === $address) { + return; + } + } + } else { + throw new \Exception(sprintf('Could not parse mail recipient: %s', print_r($address, true))); } throw new \Exception(sprintf('Did not find the recipient "%s" in the mail', $address)); }