Skip to content

Commit

Permalink
Merge branch 'release/4.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jun 29, 2023
2 parents 901f8f3 + ce732c8 commit f6ed0c3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# v4.0.3
## 06/29/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)
* 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

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
35 changes: 16 additions & 19 deletions classes/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions classes/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f6ed0c3

Please sign in to comment.