+ $contenttype = 'Content-Type: '. $mime_header->type0 .'/'.
+ $mime_header->type1;
+ if (count($message->entities)) {
+ $contenttype .= ';' . 'boundary="'.$boundary.'"';
+ }
+ if (isset($mime_header->parameters['name'])) {
+ $contenttype .= '; name="'.
+ encodeHeader($mime_header->parameters['name']). '"';
+ }
+ if (isset($mime_header->parameters['charset'])) {
+ $charset = $mime_header->parameters['charset'];
+ $contenttype .= '; charset="'.
+ encodeHeader($charset). '"';
+ }
+
+ $header[] = $contenttype . $rn;
+ if ($mime_header->description) {
+ $header[] = 'Content-Description: ' . $mime_header->description . $rn;
+ }
+ if ($mime_header->encoding) {
+ $header[] = 'Content-Transfer-Encoding: ' . $mime_header->encoding . $rn;
+ } else {
+ if ($mime_header->type0 == 'text' || $mime_header->type0 == 'message') {
+ $header[] = 'Content-Transfer-Encoding: 8bit' . $rn;
+ } else {
+ $header[] = 'Content-Transfer-Encoding: base64' . $rn;
+ }
+ }
+ if ($mime_header->id) {
+ $header[] = 'Content-ID: ' . $mime_header->id . $rn;
+ }
+ if ($mime_header->disposition) {
+ $disposition = $mime_header->disposition;
+ $contentdisp = 'Content-Disposition: ' . $disposition->name;
+ if ($disposition->getProperty('filename')) {
+ $contentdisp .= '; filename="'.
+ encodeHeader($disposition->getProperty('filename')). '"';
+ }
+ $header[] = $contentdisp . $rn;
+ }
+ if ($mime_header->md5) {
+ $header[] = 'Content-MD5: ' . $mime_header->md5 . $rn;
+ }
+ if ($mime_header->language) {
+ $header[] = 'Content-Language: ' . $mime_header->language . $rn;
+ }
+
+ $cnt = count($header);
+ $hdr_s = '';
+ for ($i = 0 ; $i < $cnt ; $i++) {
+ $hdr_s .= $this->foldLine($header[$i], 78,str_pad('',4));
+ }
+ $header = $hdr_s;
+ $header .= $rn; /* One blank line to separate mimeheader and body-entity */
+ return $header;
+ }
+
+ /**
+ * function prepareRFC822_Header - prepares the RFC822 header string from Rfc822Header object(s)
+ *
+ * This function takes the Rfc822Header object(s) and formats them
+ * into the RFC822Header string to send to the SMTP server as part
+ * of the SMTP message.
+ *
+ * @param Rfc822Header $rfc822_header
+ * @param Rfc822Header $reply_rfc822_header
+ * @param integer &$raw_length length of the message
+ *
+ * @return string $header
+ */