Skip to content

Commit

Permalink
Skip notifications for users with invalid email address.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Apr 4, 2020
1 parent 6626d9b commit 220c68a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ protected function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime
return true;
}

if (!$this->mailer->validateMailAddress($email)) {
$this->logger->warning('Notification for user "{user}" not sent because the email address "{email}" is invalid.', ['user' => $userName, 'email' => $email]);
return true;
}

list($mailData, $skippedCount) = $this->getItemsForUser($userName, $maxTime);

$l = $this->getLanguage($lang);
Expand Down
4 changes: 4 additions & 0 deletions tests/MailQueueHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ public function testSendEmailToUser(): void {
$this->mailer->expects($this->once())
->method('createEMailTemplate')
->willReturn($template);
$this->mailer->expects($this->once())
->method('validateMailAddress')
->with($email)
->willReturn(true);

$template->expects($this->once())
->method('addHeader');
Expand Down

0 comments on commit 220c68a

Please sign in to comment.