Merge pull request #7659 from owncloud/fix-7596

Fix 7596
This commit is contained in:
Vincent Petry 2014-03-11 11:36:22 +01:00
commit 0e4d522dd9
3 changed files with 23 additions and 16 deletions

View File

@ -145,10 +145,17 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
} }
$result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration); $result = $mailNotification->sendLinkShareMail($to_address, $file, $link, $expiration);
if($result === true) { if(empty($result)) {
\OCP\JSON::success(); \OCP\JSON::success();
} else { } else {
\OCP\JSON::error(array('data' => array('message' => OC_Util::sanitizeHTML($result)))); $l = OC_L10N::get('core');
OCP\JSON::error(array(
'data' => array(
'message' => $l->t("Couldn't send mail to following users: %s ",
implode(', ', $result)
)
)
));
} }
break; break;

View File

@ -72,11 +72,8 @@ class OC_Mail {
$mailo->From = $fromaddress; $mailo->From = $fromaddress;
$mailo->FromName = $fromname;; $mailo->FromName = $fromname;;
$mailo->Sender = $fromaddress; $mailo->Sender = $fromaddress;
$a=explode(' ', $toaddress);
try { try {
foreach($a as $ad) { $mailo->AddAddress($toaddress, $toname);
$mailo->AddAddress($ad, $toname);
}
if($ccaddress<>'') $mailo->AddCC($ccaddress, $ccname); if($ccaddress<>'') $mailo->AddCC($ccaddress, $ccname);
if($bcc<>'') $mailo->AddBCC($bcc); if($bcc<>'') $mailo->AddBCC($bcc);

View File

@ -97,7 +97,7 @@ class MailNotifications {
try { try {
\OCP\Util::sendMail($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail); \OCP\Util::sendMail($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
} catch (\Exception $e) { } catch (\Exception $e) {
\OCP\Util::writeLog('sharing', "Can't send mail to inform the user abaut an internal share: " . $e->getMessage() , \OCP\Util::ERROR); \OCP\Util::writeLog('sharing', "Can't send mail to inform the user about an internal share: " . $e->getMessage() , \OCP\Util::ERROR);
$noMail[] = $recipientDisplayName; $noMail[] = $recipientDisplayName;
} }
} }
@ -109,23 +109,26 @@ class MailNotifications {
/** /**
* @brief inform recipient about public link share * @brief inform recipient about public link share
* *
* @param string recipient recipient email address * @param string $recipient recipient email address
* @param string $filename the shared file * @param string $filename the shared file
* @param string $link the public link * @param string $link the public link
* @param int $expiration expiration date (timestamp) * @param int $expiration expiration date (timestamp)
* @return mixed $result true or error message * @return array $result of failed recipients
*/ */
public function sendLinkShareMail($recipient, $filename, $link, $expiration) { public function sendLinkShareMail($recipient, $filename, $link, $expiration) {
$subject = (string)$this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename)); $subject = (string)$this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename));
list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration); list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
$rs = explode(' ', $recipient);
$failed = array();
foreach ($rs as $r) {
try { try {
\OCP\Util::sendMail($recipient, $recipient, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail); \OCP\Util::sendMail($r, $r, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
} catch (\Exception $e) { } catch (\Exception $e) {
\OCP\Util::writeLog('sharing', "Can't send mail with public link: " . $e->getMessage(), \OCP\Util::ERROR); \OCP\Util::writeLog('sharing', "Can't send mail with public link to $r: " . $e->getMessage(), \OCP\Util::ERROR);
return $e->getMessage(); $failed[] = $r;
} }
}
return true; return $failed;
} }
/** /**