get('name'); } protected function _setSubject($value) { return $this->set('name', $value); } public function addAttachment(\Espo\Entities\Attachment $attachment) { if (!empty($this->id)) { $attachment->set('parentId', $this->id); $attachment->set('parentType', 'Email'); if ($this->entityManager->saveEntity($attachment)) { return true; } } } public function getBodyPlain() { $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 getBodyPlainForSending() { return $this->getBodyPlain(); } public function getBodyForSending() { $body = $this->get('body'); if (!empty($body)) { $attachmentList = $this->getInlineAttachments(); foreach ($attachmentList as $attachment) { $body = str_replace("?entryPoint=attachment&id={$attachment->id}", "cid:{$attachment->id}", $body); } } $body = str_replace("", "
", $body); return $body; } public function getInlineAttachments() { $attachmentList = array(); $body = $this->get('body'); if (!empty($body)) { if (preg_match_all("/\?entryPoint=attachment&id=([^&=\"']+)/", $body, $matches)) { if (!empty($matches[1]) && is_array($matches[1])) { foreach($matches[1] as $id) { $attachment = $this->entityManager->getEntity('Attachment', $id); if ($attachment) { $attachmentList[] = $attachment; } } } } } return $attachmentList; } public function getToList() { $value = $email->get('to'); if ($value) { $arr = explode(';', $value); if (is_array($arr)) { return $arr; } } return []; } public function getCcList() { $value = $email->get('cc'); if ($value) { $arr = explode(';', $value); if (is_array($arr)) { return $arr; } } return []; } public function getBccList() { $value = $email->get('bcc'); if ($value) { $arr = explode(';', $value); if (is_array($arr)) { return $arr; } } return []; } public function getReplyToList() { $value = $email->get('replyTo'); if ($value) { $arr = explode(';', $value); if (is_array($arr)) { return $arr; } } return []; } }