diff --git a/application/Espo/Core/Mail/Importer.php b/application/Espo/Core/Mail/Importer.php index a24b6a0e55..3302dcbbcc 100644 --- a/application/Espo/Core/Mail/Importer.php +++ b/application/Espo/Core/Mail/Importer.php @@ -102,11 +102,15 @@ class Importer return false; } + if (isset($message->messageId) && !empty($message->messageId)) { $email->set('messageId', $message->messageId); if (isset($message->deliveredTo)) { $email->set('messageIdInternal', $message->messageId . '-' . $message->deliveredTo); } + if (stripos($message->messageId, '@espo-system') !== false) { + return; + } } if ($duplicate = $this->findDuplicate($email)) { diff --git a/application/Espo/Core/Mail/Sender.php b/application/Espo/Core/Mail/Sender.php index 0109cee842..520e3d13bb 100644 --- a/application/Espo/Core/Mail/Sender.php +++ b/application/Espo/Core/Mail/Sender.php @@ -321,6 +321,9 @@ class Sender } else { $messageId = '' . md5($email->get('name')) . '/' . time() . '/' . $rand . '@espo'; } + if ($email->get('isSystem')) { + $messageId .= '-system'; + } $messageIdHeader = new \Zend\Mail\Header\MessageId(); $messageIdHeader->setId($messageId); diff --git a/application/Espo/Resources/i18n/en_US/Admin.json b/application/Espo/Resources/i18n/en_US/Admin.json index ccc413e1fc..bd0630fff8 100644 --- a/application/Espo/Resources/i18n/en_US/Admin.json +++ b/application/Espo/Resources/i18n/en_US/Admin.json @@ -116,7 +116,8 @@ "seeMoreDisabled": "Disable Text Cut", "entityList": "Entity List", "isSorted": "Is Sorted (alphabetically)", - "audited": "Audited" + "audited": "Audited", + "trim": "Trim" }, "messages": { "upgradeVersion": "Your EspoCRM will be upgraded to version {version}. This can take some time.", diff --git a/application/Espo/Resources/metadata/entityDefs/Email.json b/application/Espo/Resources/metadata/entityDefs/Email.json index 425f91ca40..081678a8e2 100644 --- a/application/Espo/Resources/metadata/entityDefs/Email.json +++ b/application/Espo/Resources/metadata/entityDefs/Email.json @@ -172,6 +172,11 @@ "type": "linkMultiple", "readOnly": true }, + "isSystem": { + "type": "bool", + "default": false, + "readOnly": true + }, "teams": { "type": "linkMultiple" }, diff --git a/application/Espo/Resources/metadata/entityDefs/EmailAccount.json b/application/Espo/Resources/metadata/entityDefs/EmailAccount.json index 168e639991..bbf86b47cb 100644 --- a/application/Espo/Resources/metadata/entityDefs/EmailAccount.json +++ b/application/Espo/Resources/metadata/entityDefs/EmailAccount.json @@ -8,6 +8,7 @@ "type": "varchar", "required": true, "maxLength": 100, + "trim": true, "view": "EmailAccount.Fields.EmailAddress" }, "status": { diff --git a/application/Espo/Resources/metadata/entityDefs/InboundEmail.json b/application/Espo/Resources/metadata/entityDefs/InboundEmail.json index ea6f37af74..ef01b2b6ac 100644 --- a/application/Espo/Resources/metadata/entityDefs/InboundEmail.json +++ b/application/Espo/Resources/metadata/entityDefs/InboundEmail.json @@ -8,7 +8,8 @@ "type": "varchar", "required": true, "maxLength": 100, - "view": "EmailAccount.Fields.EmailAddress" + "view": "EmailAccount.Fields.EmailAddress", + "trim": true }, "status": { "type": "enum", diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index c3f3013237..f9fa0d3ebb 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -84,7 +84,8 @@ "outboundEmailFromAddress": { "type": "varchar", "default": "crm@example.com", - "required": true + "required": true, + "trim": true }, "smtpServer": { "type": "varchar", diff --git a/application/Espo/Resources/metadata/fields/varchar.json b/application/Espo/Resources/metadata/fields/varchar.json index 09961b3f7e..64e9e63531 100644 --- a/application/Espo/Resources/metadata/fields/varchar.json +++ b/application/Espo/Resources/metadata/fields/varchar.json @@ -13,6 +13,10 @@ "name":"maxLength", "type":"int" }, + { + "name":"trim", + "type":"bool" + }, { "name":"audited", "type":"bool" diff --git a/application/Espo/Services/EmailNotification.php b/application/Espo/Services/EmailNotification.php index 94ee0858ef..ca56d2552b 100644 --- a/application/Espo/Services/EmailNotification.php +++ b/application/Espo/Services/EmailNotification.php @@ -105,7 +105,8 @@ class EmailNotification extends \Espo\Core\Services\Base 'subject' => $subject, 'body' => $body, 'isHtml' => false, - 'to' => $emailAddress + 'to' => $emailAddress, + 'isSystem' => true )); $this->getMailSender()->send($email); diff --git a/frontend/client/src/views/fields/varchar.js b/frontend/client/src/views/fields/varchar.js index 2ee2188df9..a5f8097868 100644 --- a/frontend/client/src/views/fields/varchar.js +++ b/frontend/client/src/views/fields/varchar.js @@ -31,8 +31,23 @@ Espo.define('Views.Fields.Varchar', 'Views.Fields.Base', function (Dep) { this.searchParams.typeOptions = ['startsWith', 'contains', 'equals']; }, + fetch: function () { + var data = {}; + var value = this.$element.val(); + if (this.params.trim) { + if (typeof value.trim === 'function') { + value = value.trim(); + } + } + data[this.name] = value; + return data; + }, + fetchSearch: function () { var value = this.$element.val(); + if (typeof value.trim === 'function') { + value = value.trim(); + } var type = this.$el.find('[name="'+this.name+'-type"]').val() || 'startsWith'; if (value) { var data = {