Skip to content

Commit

Permalink
handle mail send error gracefully
Browse files Browse the repository at this point in the history
log the error in case a notification mail of a new share couldn't
be send to the recipient and finish the share operation successfully

Signed-off-by: Bjoern Schiessle <[email protected]>
  • Loading branch information
schiessle authored and ChristophWurst committed Jan 30, 2019
1 parent 29a5661 commit a943580
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ public function createShare(\OCP\Share\IShare $share) {
* @param string $initiator user ID of share sender
* @param string $shareWith email address of share receiver
* @param \DateTime|null $expiration
* @throws \Exception If mail couldn't be sent
* @return bool
*/
protected function sendMailNotification(IL10N $l,
$filename,
Expand Down Expand Up @@ -773,7 +773,18 @@ protected function sendMailNotification(IL10N $l,
}

$message->useTemplate($emailTemplate);
$this->mailer->send($message);
try {
$failedRecipients = $this->mailer->send($message);
if(!empty($failedRecipients)) {
$this->logger->error('Share notification mail could not be send to: ' . implode(', ', $failedRecipients));
return false;
}
} catch (\Exception $e) {
$this->logger->error('Share notification mail could not be send: ' . $e->getMessage());
return false;
}

return true;
}

/**
Expand Down

0 comments on commit a943580

Please sign in to comment.