From c4c59aaf39ae1ad62d31048a8646c464198e1727 Mon Sep 17 00:00:00 2001 From: "pastripodi@owncloud.com" Date: Mon, 2 Dec 2019 13:20:12 +0100 Subject: [PATCH] Add validation for sender email address --- changelog/unreleased/36505 | 5 +++++ lib/private/Share/MailNotifications.php | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 changelog/unreleased/36505 diff --git a/changelog/unreleased/36505 b/changelog/unreleased/36505 new file mode 100644 index 000000000000..018d030044f7 --- /dev/null +++ b/changelog/unreleased/36505 @@ -0,0 +1,5 @@ +Bugfix: enhance validation for sender e-mail address for e-mail notifications + +In case an user wanted to use the e-mail notification mechanism in order to notify other users when creating public links as well as internal shares, an error was triggered if the e-mail address for this user was not set. The behavior has now been fixed. + +https://github.com/owncloud/core/pull/36505 diff --git a/lib/private/Share/MailNotifications.php b/lib/private/Share/MailNotifications.php index b5b7ac9a9856..29b0e7c40a57 100644 --- a/lib/private/Share/MailNotifications.php +++ b/lib/private/Share/MailNotifications.php @@ -183,6 +183,10 @@ public function sendInternalShareMail($sender, $node, $shareType, $recipientList 'internal', $recipientL10N ); + $replyTo = $sender->getEMailAddress(); + if (empty($replyTo)) { + $replyTo = Util::getDefaultEmailAddress('sharing-noreply'); + } // send it out now try { @@ -192,7 +196,7 @@ public function sendInternalShareMail($sender, $node, $shareType, $recipientList $message->setHtmlBody($htmlBody); $message->setPlainBody($textBody); $message->setFrom($this->getFrom($this->l, $filter->getSenderDisplayName())); - $message->setReplyTo([$sender->getEMailAddress()]); + $message->setReplyTo([$replyTo]); $this->mailer->send($message); } catch (\Exception $e) { @@ -264,6 +268,9 @@ public function sendLinkShareMail($sender, $recipients, $link, $personalNote = n ); $from = $this->getFrom($l10n, $filter->getSenderDisplayName()); $replyTo = $sender->getEMailAddress(); + if (empty($replyTo)) { + $replyTo = Util::getDefaultEmailAddress('sharing-noreply'); + } $event = new GenericEvent(null, ['link' => $link, 'to' => $recipientsAsString]); $this->eventDispatcher->dispatch('share.sendmail', $event);