From a3bc3bbf2d2a611cf06709bf720d4b31edbc568b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Tue, 11 Mar 2014 14:28:53 +0100 Subject: [PATCH 1/2] backport #7659 --- core/ajax/share.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/core/ajax/share.php b/core/ajax/share.php index c251f8e7bae..a7fecf33f30 100644 --- a/core/ajax/share.php +++ b/core/ajax/share.php @@ -231,12 +231,27 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo $from_address = OCP\Config::getUserValue($user, 'settings', 'email', $default_from ); // send it out now - try { - OCP\Util::sendMail($to_address, $to_address, $subject, $text, $from_address, $displayName, 1, $alttext); - OCP\JSON::success(); - } catch (Exception $exception) { - OCP\JSON::error(array('data' => array('message' => OC_Util::sanitizeHTML($exception->getMessage())))); + $rs = explode(' ', $to_address); + $failed = array(); + foreach ($rs as $r) { + try { + \OCP\Util::sendMail($r, $r, $subject, $text, $from_address, $displayName, 1, $alttext); + } catch (\Exception $e) { + \OCP\Util::writeLog('sharing', "Can't send mail with public link to $r: " . $e->getMessage(), \OCP\Util::ERROR); + $failed[] = $r; + } } + + if (empty($failed)) { + OCP\JSON::success(); + } else { + OCP\JSON::error(array( + 'data' => array( + 'message' => $l->t("Couldn't send mail to following users: %s ", + implode(', ', $failed) + ) + ) + )); } break; } } else if (isset($_GET['fetch'])) { From c1c6ce22e88ccc2fb492ca2886c18453fe0e23e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 10 Mar 2014 21:56:37 +0100 Subject: [PATCH 2/2] remove magic handling of recipient lists by exploding the string - this functionality is nowhere used this way and nowhere documented - and broken because only $toaddress will be exploded not $toname --- lib/private/mail.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/private/mail.php b/lib/private/mail.php index b339b33e962..27dc6d3d8ca 100644 --- a/lib/private/mail.php +++ b/lib/private/mail.php @@ -72,11 +72,8 @@ class OC_Mail { $mailo->From = $fromaddress; $mailo->FromName = $fromname;; $mailo->Sender = $fromaddress; - $a=explode(' ', $toaddress); try { - foreach($a as $ad) { - $mailo->AddAddress($ad, $toname); - } + $mailo->AddAddress($toaddress, $toname); if($ccaddress<>'') $mailo->AddCC($ccaddress, $ccname); if($bcc<>'') $mailo->AddBCC($bcc);