Skip to content

EspoCRM – Open Source CRM Application

Email body plain fix

Yurii10b923c68b09
diff --git a/application/Espo/Classes/RecordHooks/Email/BeforeSave.php b/application/Espo/Classes/RecordHooks/Email/BeforeSave.php
index 4ee173a831..d4fa21b1a9 100644
--- a/application/Espo/Classes/RecordHooks/Email/BeforeSave.php
+++ b/application/Espo/Classes/RecordHooks/Email/BeforeSave.php
@@ -55,11 +55,17 @@ class BeforeSave implements SaveHook
private function processBodyPlain(Email $entity): void
{
- if (!$entity->isHtml() || !$entity->isAttributeChanged('body')) {
+ if (!$entity->isAttributeChanged('body')) {
return;
}
- $body = $entity->getBody();
+ $body = $entity->getBody() ?: null;
+
+ if (!$entity->isHtml()) {
+ $entity->setBodyPlain($body);
+
+ return;
+ }
if ($body) {
$body = Util::stripHtml($body) ?: null;