From 3c19cb6a55ac76b25bc6567dc605648d84ac3fe3 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Jun 2023 11:55:03 -0600 Subject: [PATCH 1/4] fixes #176 --- CHANGELOG.md | 8 ++++++++ classes/Email.php | 35 ++++++++++++++++------------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f43812d..b3e0465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +# v4.0.3 +## mm/dd/2023 + +1. [](#improved) + * Simplified the `Email::processRecipients()` logic for readability +1. [](#bugfix) + * Fix an issue with 2 email addresses provided with 'just' email and no name [#176](https://github.com/getgrav/grav-plugin-email/issues/176) + # v4.0.2 ## 06/27/2023 diff --git a/classes/Email.php b/classes/Email.php index 949b0cd..1bc7b1d 100644 --- a/classes/Email.php +++ b/classes/Email.php @@ -253,33 +253,30 @@ protected function processRecipients(string $type, array $params): array $list = []; if (!empty($recipients)) { - if (is_array($recipients) && Utils::isAssoc($recipients)) { - $list[] = $this->createAddress($recipients); + if (is_array($recipients)) { + if (Utils::isAssoc($recipients) || (count($recipients) ===2 && $this->isValidEmail($recipients[0]) && !$this->isValidEmail($recipients[1]))) { + $list[] = $this->createAddress($recipients); + } else { + foreach ($recipients as $recipient) { + $list[] = $this->createAddress($recipient); + } + } } else { - if (is_array($recipients)) { - if (count($recipients) ===2 && $this->isValidEmail($recipients[0]) && is_string($recipients[1])) { - $list[] = $this->createAddress($recipients); - } else { - foreach ($recipients as $recipient) { - $list[] = $this->createAddress($recipient); - } + if (is_string($recipients) && Utils::contains($recipients, ',')) { + $recipients = array_map('trim', explode(',', $recipients)); + foreach ($recipients as $recipient) { + $list[] = $this->createAddress($recipient); } } else { - if (is_string($recipients) && Utils::contains($recipients, ',')) { - $recipients = array_map('trim', explode(',', $recipients)); - foreach ($recipients as $recipient) { - $list[] = $this->createAddress($recipient); - } - } else { - if (!Utils::contains($recipients, ['<','>']) && (isset($params[$type."_name"]))) { - $recipients = [$recipients, $params[$type."_name"]]; - } - $list[] = $this->createAddress($recipients); + if (!Utils::contains($recipients, ['<','>']) && (isset($params[$type."_name"]))) { + $recipients = [$recipients, $params[$type."_name"]]; } + $list[] = $this->createAddress($recipients); } } } + return $list; } From 41b46e636c809ff52dec92881d3aa4a386f6c4de Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Jun 2023 13:31:20 -0600 Subject: [PATCH 2/4] Added missing method for `Message::setSubject()` - fixes getgrav/grav-plugin-login#299 --- classes/Message.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/classes/Message.php b/classes/Message.php index fb691f8..066a209 100644 --- a/classes/Message.php +++ b/classes/Message.php @@ -18,6 +18,12 @@ public function subject($subject): self return $this; } + public function setSubject($subject): self + { + $this->subject($subject); + return $this; + } + public function to($to): self { $this->email->to($to); From ce301b14606693e028c9f6a4bb0a466737059972 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Jun 2023 13:32:20 -0600 Subject: [PATCH 3/4] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3e0465..2da60df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Simplified the `Email::processRecipients()` logic for readability 1. [](#bugfix) * Fix an issue with 2 email addresses provided with 'just' email and no name [#176](https://github.com/getgrav/grav-plugin-email/issues/176) + * Fix for blank subjectlines when using `Message::setSubject()` in Twig templates [getgrav/grav-plugin-login#299](https://github.com/getgrav/grav-plugin-login/issues/299) # v4.0.2 ## 06/27/2023 From ce732c8fca25e1eea32a42c15395cf2ea2054bc5 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Jun 2023 13:34:45 -0600 Subject: [PATCH 4/4] prepare for release --- CHANGELOG.md | 2 +- blueprints.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da60df..b47ce53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v4.0.3 -## mm/dd/2023 +## 06/29/2023 1. [](#improved) * Simplified the `Email::processRecipients()` logic for readability diff --git a/blueprints.yaml b/blueprints.yaml index 995b4c3..442a62c 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Email slug: email type: plugin -version: 4.0.2 +version: 4.0.3 testing: false description: Enables the emailing system for Grav icon: envelope