/** * Builds the right content-type/encoding types based on file and * content-type. * * Will return a string containing the section, or an empty array on * failure. Can be used to send to an email server directly. * @return string */ public function contentInfoArray($type = NULL, $file = NULL) { $description = array('multipart/mixed' => array("Content-Type" => 'multipart/mixed; boundary="' . $this->getBoundary('multipart/mixed') . '"'), 'multipart/alternative' => array('Content-Type' => 'multipart/alternative; boundary="' . $this->getBoundary('multipart/alternative') . '"'), 'text/plain' => array('Content-Type' => 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding' => $this->_text_encoding ? $this->_text_encoding : '8bit'), 'text/html' => array('Content-Type' => 'text/html; charset=UTF-8', 'Content-Transfer-Encoding' => $this->_text_encoding ? $this->_text_encoding : '8bit')); $binary = array('Content-Type' => EmailHelper::getMimeType($file) . '; name="' . basename($file) . '"', 'Content-Transfer-Encoding' => 'base64', 'Content-Disposition' => 'attachment; filename="' . basename($file) . '"'); return !empty($description[$type]) ? $description[$type] : ($file ? $binary : array()); }