diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index ad92ad15c7..5a1d90105e 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -201,23 +201,21 @@ class Sender $body = new MimeMessage; $parts = array(); - + + $bodyPart = new MimePart($email->getBodyPlainForSending()); + $bodyPart->type = 'text/plain'; + $bodyPart->charset = 'utf-8'; + $parts[] = $bodyPart; + + if ($email->get('isHtml')) { $bodyPart = new MimePart($email->getBodyForSending()); $bodyPart->type = 'text/html'; $bodyPart->charset = 'utf-8'; - } else { - if ($email->get('bodyPlain')) { - $bodyPart = new MimePart($email->get('bodyPlain')); - } else { - $bodyPart = new MimePart($email->get('body')); - } - $bodyPart->type = 'text/plain'; - $bodyPart->charset = 'utf-8'; + $parts[] = $bodyPart; } - - $parts[] = $bodyPart; + $aCollection = $email->get('attachments'); if (!empty($aCollection)) { @@ -251,6 +249,10 @@ class Sender $body->setParts($parts); $message->setBody($body); + + if ($email->get('isHtml')) { + $message->getHeaders()->get('content-type')->setType('multipart/alternative'); + } try { $this->transport->send($message); diff --git a/application/Espo/Entities/Email.php b/application/Espo/Entities/Email.php index 6f2e144397..1139f45b50 100644 --- a/application/Espo/Entities/Email.php +++ b/application/Espo/Entities/Email.php @@ -46,6 +46,21 @@ class Email extends \Espo\Core\ORM\Entity } } + public function getBodyPlainForSending() + { + $bodyPlain = $this->get('bodyPlain'); + if (!empty($bodyPlain)) { + return $bodyPlain; + } + + $body = $this->get('body'); + + $breaks = array("
","
","
","
","<br />","<br/>","<br>"); + $body = str_ireplace($breaks, "\r\n", $body); + $body = strip_tags($body); + return $body; + } + public function getBodyForSending() { $body = $this->get('body'); @@ -55,6 +70,7 @@ class Email extends \Espo\Core\ORM\Entity $body = str_replace("?entryPoint=attachment&id={$attachment->id}", "cid:{$attachment->id}", $body); } } + $body = str_replace("", "
", $body); return $body; diff --git a/frontend/client/src/views/admin/upgrade/index.js b/frontend/client/src/views/admin/upgrade/index.js index 41a39973d0..5cc5d0d860 100644 --- a/frontend/client/src/views/admin/upgrade/index.js +++ b/frontend/client/src/views/admin/upgrade/index.js @@ -71,7 +71,8 @@ Espo.define('Views.Admin.Upgrade.Index', 'View', function (Dep) { $.ajax({ url: 'Admin/action/uploadUpgradePackage', type: 'POST', - contentType: 'application/zip', + contentType: 'application/zip', + timeout: 0, data: this.packageContents, error: function (xhr, t, e) { this.showError(xhr.getResponseHeader('X-Status-Reason')); diff --git a/frontend/client/src/views/import/step2.js b/frontend/client/src/views/import/step2.js index 7f9f241fd4..b5057a1515 100644 --- a/frontend/client/src/views/import/step2.js +++ b/frontend/client/src/views/import/step2.js @@ -289,6 +289,7 @@ Espo.define('Views.Import.Step2', 'View', function (Dep) { url: 'Import/action/uploadFile', contentType: 'text/csv', data: this.getParentView().fileContents, + timeout: 0, success: function (data) { if (data.attachmentId) { this.runImport(data.attachmentId);