@@ -692,29 +692,32 @@ public function createShare(\OCP\Share\IShare $share) {
692692 $ emailAddress ,
693693 $ share ->getExpirationDate ()
694694 );
695- $ this ->logger ->debug ('Send share notification to ' . $ emailAddress . ' for share with ID ' . $ share ->getId (), ['app ' => 'share ' ]);
695+ $ this ->logger ->debug ('Sent share notification to ' . $ emailAddress . ' for share with ID ' . $ share ->getId (), ['app ' => 'share ' ]);
696696 } else {
697- $ this ->logger ->debug ('Share notification not send to ' . $ share ->getSharedWith () . ' because email address is not set. ' , ['app ' => 'share ' ]);
697+ $ this ->logger ->debug ('Share notification not sent to ' . $ share ->getSharedWith () . ' because email address is not set. ' , ['app ' => 'share ' ]);
698698 }
699699 } else {
700- $ this ->logger ->debug ('Share notification not send to ' . $ share ->getSharedWith () . ' because user could not be found. ' , ['app ' => 'share ' ]);
700+ $ this ->logger ->debug ('Share notification not sent to ' . $ share ->getSharedWith () . ' because user could not be found. ' , ['app ' => 'share ' ]);
701701 }
702702 } else {
703- $ this ->logger ->debug ('Share notification not send because mailsend is false. ' , ['app ' => 'share ' ]);
703+ $ this ->logger ->debug ('Share notification not sent because mailsend is false. ' , ['app ' => 'share ' ]);
704704 }
705705 }
706706
707707 return $ share ;
708708 }
709709
710710 /**
711+ * Send mail notifications
712+ *
713+ * This method will catch and log mail transmission errors
714+ *
711715 * @param IL10N $l Language of the recipient
712716 * @param string $filename file/folder name
713717 * @param string $link link to the file/folder
714718 * @param string $initiator user ID of share sender
715719 * @param string $shareWith email address of share receiver
716720 * @param \DateTime|null $expiration
717- * @throws \Exception If mail couldn't be sent
718721 */
719722 protected function sendMailNotification (IL10N $ l ,
720723 $ filename ,
@@ -773,7 +776,15 @@ protected function sendMailNotification(IL10N $l,
773776 }
774777
775778 $ message ->useTemplate ($ emailTemplate );
776- $ this ->mailer ->send ($ message );
779+ try {
780+ $ failedRecipients = $ this ->mailer ->send ($ message );
781+ if (!empty ($ failedRecipients )) {
782+ $ this ->logger ->error ('Share notification mail could not be sent to: ' . implode (', ' , $ failedRecipients ));
783+ return ;
784+ }
785+ } catch (\Exception $ e ) {
786+ $ this ->logger ->logException ($ e , ['message ' => 'Share notification mail could not be sent ' ]);
787+ }
777788 }
778789
779790 /**
0 commit comments