Skip to content

Commit f6ed0c3

Browse files
committed
Merge branch 'release/4.0.3'
2 parents 901f8f3 + ce732c8 commit f6ed0c3

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# v4.0.3
2+
## 06/29/2023
3+
4+
1. [](#improved)
5+
* Simplified the `Email::processRecipients()` logic for readability
6+
1. [](#bugfix)
7+
* Fix an issue with 2 email addresses provided with 'just' email and no name [#176](https://github.com/getgrav/grav-plugin-email/issues/176)
8+
* 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)
9+
110
# v4.0.2
211
## 06/27/2023
312

blueprints.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Email
22
slug: email
33
type: plugin
4-
version: 4.0.2
4+
version: 4.0.3
55
testing: false
66
description: Enables the emailing system for Grav
77
icon: envelope

classes/Email.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -253,33 +253,30 @@ protected function processRecipients(string $type, array $params): array
253253
$list = [];
254254

255255
if (!empty($recipients)) {
256-
if (is_array($recipients) && Utils::isAssoc($recipients)) {
257-
$list[] = $this->createAddress($recipients);
256+
if (is_array($recipients)) {
257+
if (Utils::isAssoc($recipients) || (count($recipients) ===2 && $this->isValidEmail($recipients[0]) && !$this->isValidEmail($recipients[1]))) {
258+
$list[] = $this->createAddress($recipients);
259+
} else {
260+
foreach ($recipients as $recipient) {
261+
$list[] = $this->createAddress($recipient);
262+
}
263+
}
258264
} else {
259-
if (is_array($recipients)) {
260-
if (count($recipients) ===2 && $this->isValidEmail($recipients[0]) && is_string($recipients[1])) {
261-
$list[] = $this->createAddress($recipients);
262-
} else {
263-
foreach ($recipients as $recipient) {
264-
$list[] = $this->createAddress($recipient);
265-
}
265+
if (is_string($recipients) && Utils::contains($recipients, ',')) {
266+
$recipients = array_map('trim', explode(',', $recipients));
267+
foreach ($recipients as $recipient) {
268+
$list[] = $this->createAddress($recipient);
266269
}
267270
} else {
268-
if (is_string($recipients) && Utils::contains($recipients, ',')) {
269-
$recipients = array_map('trim', explode(',', $recipients));
270-
foreach ($recipients as $recipient) {
271-
$list[] = $this->createAddress($recipient);
272-
}
273-
} else {
274-
if (!Utils::contains($recipients, ['<','>']) && (isset($params[$type."_name"]))) {
275-
$recipients = [$recipients, $params[$type."_name"]];
276-
}
277-
$list[] = $this->createAddress($recipients);
271+
if (!Utils::contains($recipients, ['<','>']) && (isset($params[$type."_name"]))) {
272+
$recipients = [$recipients, $params[$type."_name"]];
278273
}
274+
$list[] = $this->createAddress($recipients);
279275
}
280276
}
281277
}
282278

279+
283280
return $list;
284281
}
285282

classes/Message.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public function subject($subject): self
1818
return $this;
1919
}
2020

21+
public function setSubject($subject): self
22+
{
23+
$this->subject($subject);
24+
return $this;
25+
}
26+
2127
public function to($to): self
2228
{
2329
$this->email->to($to);

0 commit comments

Comments
 (0)