From 0a389112ca0e09332a2bca6ab0cc52afeb56206e Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 7 Sep 2021 11:20:29 +1200 Subject: [PATCH 1/2] FIX Only send email if email address set --- src/Security/Member.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Security/Member.php b/src/Security/Member.php index c88ea357d..7150507e8 100644 --- a/src/Security/Member.php +++ b/src/Security/Member.php @@ -910,6 +910,7 @@ class Member extends DataObject if ((Director::isLive() || Injector::inst()->get(Mailer::class) instanceof TestMailer) && $this->isChanged('Password') && $this->record['Password'] + && $this->Email && static::config()->get('notify_password_change') && $this->isInDB() ) { From 1c698348a21d0492bff362b2207f4802edb79229 Mon Sep 17 00:00:00 2001 From: Maxime Rainville Date: Thu, 9 Sep 2021 19:23:37 +1200 Subject: [PATCH 2/2] BUG When asserting an email was sent, sanitise both the To and From field --- src/Dev/TestMailer.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Dev/TestMailer.php b/src/Dev/TestMailer.php index 8c949e296..3d37b0ded 100644 --- a/src/Dev/TestMailer.php +++ b/src/Dev/TestMailer.php @@ -103,17 +103,18 @@ class TestMailer implements Mailer foreach ($this->emailsSent as $email) { $matched = true; - foreach (['To', 'From', 'Subject', 'Content'] as $field) { + // Loop all our Email fields + foreach ($compare as $field => $value) { $emailValue = $email[$field]; - if ($value = $compare[$field]) { - if ($field == 'To') { + if ($value) { + if (in_array($field, ['To', 'From'])) { $emailValue = $this->normaliseSpaces($emailValue); $value = $this->normaliseSpaces($value); } - if ($value[0] == '/') { + if ($value[0] === '/') { $matched = preg_match($value, $emailValue); } else { - $matched = ($value == $emailValue); + $matched = ($value === $emailValue); } if (!$matched) { break;