Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip notifications for users with invalid email address. #448

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
nickvergessen marked this conversation as resolved.
Show resolved Hide resolved
}

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