$link = $_POST['link'];
$text = $user.' shared the '.$type.' '.$_POST['file'].' with you. It is available for download here: '.$link;
$fromaddress = OCP\Config::getUserValue($user, 'settings', 'email', 'sharing-noreply@'.OCP\Util::getServerHost());
-OCP\Util::sendMail($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user);
+try {
+ OCP\Util::sendMail($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user);
+ OCP\JSON::success();
+} catch (Exception $exception) {
+ OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
+}
emailPrivateLink:function() {
var link = $('#privateLinkText').val();
var file = link.substr(link.lastIndexOf('/') + 1).replace(/%20/g, ' ');
- $.post(OC.filePath('files_sharing', 'ajax', 'email.php'), { toaddress: $('#email').val(), link: link, file: file } );
- $('#email').css('font-weight', 'bold');
- $('#email').animate({ fontWeight: 'normal' }, 2000, function() {
- $(this).val('');
- }).val('Email sent');
+ var email = $('#email').val();
+ if (email != '') {
+ $.post(OC.filePath('files_sharing', 'ajax', 'email.php'), { toaddress: email, link: link, file: file }, function(result) {
+ if (result && result.status == 'success') {
+ $('#email').css('font-weight', 'bold');
+ $('#email').animate({ fontWeight: 'normal' }, 2000, function() {
+ $(this).val('');
+ }).val('Email sent');
+ } else {
+ OC.dialogs.alert(result.data.message, 'Error while sharing');
+ }
+ });
+ }
},
dirname:function(path) {
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
unset($mailo);
OC_Log::write('mail', 'Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject, OC_Log::DEBUG);
} catch (Exception $exception) {
- OC_Log::write('mail', $exception->getMessage(), OC_Log::DEBUG);
+ OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
+ throw($exception);
}
}