/** * Prepares message for sending * * Calls MIME etc encodings as necessary. */ private function _prepare_message() { if (!empty($this->parameters)) { $template_helper = new org_openpsa_mail_template($this->parameters); $this->headers['Subject'] = $template_helper->parse($this->headers['Subject']); $this->body = $template_helper->parse($this->body); $this->html_body = $template_helper->parse($this->html_body); } //Translate newlines $this->body = preg_replace("/\n\r|\r\n|\r/", "\n", $this->body); $this->html_body = preg_replace("/\n\r|\r\n|\r/", "\n", $this->html_body); //Try to translate HTML-only body to plaintext as well if (strlen($this->body) == 0 && strlen($this->html_body) > 0 && !$this->allow_only_html) { $this->body = $this->html2text($this->html_body); } $message = new org_openpsa_mail_message($this->to, $this->headers, $this->encoding); //Check whether it's necessary to initialize MIME if (!empty($this->html_body) || !empty($this->attachments) || !empty($this->_embeds)) { $message->set_mime_body($this->body, $this->html_body, $this->attachments, $this->_embeds); } else { $message->set_body($this->body); } return $message; }