diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-01-31 11:10:26 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-31 11:10:26 +0300 |
commit | 1fd8e68fa0485cb85df6ff7ce0171279b0daaae0 (patch) | |
tree | 7a6edcaef1147683027f65b325144b6bd02d5f9b | |
parent | 1572b2661e72f6626ccf791baa4ca3da777141f0 (diff) | |
parent | a7c897b4458d64cd64a5aded471760119f0dd8c1 (diff) |
Merge pull request #13931 from nextcloud/backport/12636/stable14
[stable14] handle mail send error gracefully
-rw-r--r-- | lib/private/Share20/Manager.php | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 9497b2c2637..57b1db155d9 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -692,15 +692,15 @@ class Manager implements IManager { $emailAddress, $share->getExpirationDate() ); - $this->logger->debug('Send share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); + $this->logger->debug('Sent share notification to ' . $emailAddress . ' for share with ID ' . $share->getId(), ['app' => 'share']); } else { - $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']); + $this->logger->debug('Share notification not sent to ' . $share->getSharedWith() . ' because email address is not set.', ['app' => 'share']); } } else { - $this->logger->debug('Share notification not send to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']); + $this->logger->debug('Share notification not sent to ' . $share->getSharedWith() . ' because user could not be found.', ['app' => 'share']); } } else { - $this->logger->debug('Share notification not send because mailsend is false.', ['app' => 'share']); + $this->logger->debug('Share notification not sent because mailsend is false.', ['app' => 'share']); } } @@ -708,13 +708,16 @@ class Manager implements IManager { } /** + * Send mail notifications + * + * This method will catch and log mail transmission errors + * * @param IL10N $l Language of the recipient * @param string $filename file/folder name * @param string $link link to the file/folder * @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 */ protected function sendMailNotification(IL10N $l, $filename, @@ -773,7 +776,15 @@ class Manager implements IManager { } $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 sent to: ' . implode(', ', $failedRecipients)); + return; + } + } catch (\Exception $e) { + $this->logger->logException($e, ['message' => 'Share notification mail could not be sent']); + } } /** |