+ $header[] = "Date: $date" . $rn;
+ $header[] = 'Subject: '.encodeHeader($rfc822_header->subject) . $rn;
+ $header[] = 'From: '. $rfc822_header->getAddr_s('from',",$rn ",true) . $rn;
+
+ // folding address list [From|To|Cc|Bcc] happens by using ",$rn<space>" as delimiter
+ // Do not use foldLine for that.
+
+ // RFC2822 if from contains more then 1 address
+ if (count($rfc822_header->from) > 1) {
+ $header[] = 'Sender: '. $rfc822_header->getAddr_s('sender',',',true) . $rn;
+ }
+ if (count($rfc822_header->to)) {
+ $header[] = 'To: '. $rfc822_header->getAddr_s('to',",$rn ",true) . $rn;
+ }
+ if (count($rfc822_header->cc)) {
+ $header[] = 'Cc: '. $rfc822_header->getAddr_s('cc',",$rn ",true) . $rn;
+ }
+ if (count($rfc822_header->reply_to)) {
+ $header[] = 'Reply-To: '. $rfc822_header->getAddr_s('reply_to',',',true) . $rn;
+ }
+ /* Sendmail should return true. Default = false */
+ $bcc = $this->getBcc();
+ if (count($rfc822_header->bcc)) {
+ $s = 'Bcc: '. $rfc822_header->getAddr_s('bcc',",$rn ",true) . $rn;
+ if (!$bcc) {
+ $raw_length += strlen($s);
+ } else {
+ $header[] = $s;
+ }
+ }
+ /* Identify SquirrelMail */
+ $header[] = 'User-Agent: SquirrelMail/' . $version . $rn;
+ /* Do the MIME-stuff */
+ $header[] = 'MIME-Version: 1.0' . $rn;
+ $contenttype = 'Content-Type: '. $rfc822_header->content_type->type0 .'/'.
+ $rfc822_header->content_type->type1;
+ if (count($rfc822_header->content_type->properties)) {
+ foreach ($rfc822_header->content_type->properties as $k => $v) {
+ if ($k && $v) {
+ $contenttype .= ';' .$k.'='.$v;
+ }
+ }
+ }
+ $header[] = $contenttype . $rn;
+ if ($encoding = $rfc822_header->encoding) {
+ $header[] .= 'Content-Transfer-Encoding: ' . $encoding . $rn;
+ }
+ if ($rfc822_header->dnt) {
+ $dnt = $rfc822_header->getAddr_s('dnt');
+ /* Pegasus Mail */
+ $header[] = 'X-Confirm-Reading-To: '.$dnt. $rn;
+ /* RFC 2298 */
+ $header[] = 'Disposition-Notification-To: '.$dnt. $rn;
+ }
+ if ($rfc822_header->priority) {
+ switch($rfc822_header->priority)
+ {
+ case 1:
+ $header[] = 'X-Priority: 1 (Highest)'.$rn;
+ $header[] = 'Importance: High'. $rn; break;
+ case 3:
+ $header[] = 'X-Priority: 3 (Normal)'.$rn;
+ $header[] = 'Importance: Normal'. $rn; break;
+ case 5:
+ $header[] = 'X-Priority: 5 (Lowest)'.$rn;
+ $header[] = 'Importance: Low'. $rn; break;
+ default: break;
+ }
+ }
+ /* Insert headers from the $more_headers array */
+ if(count($rfc822_header->more_headers)) {
+ reset($rfc822_header->more_headers);
+ foreach ($rfc822_header->more_headers as $k => $v) {
+ $header[] = $k.': '.$v .$rn;
+ }
+ }
+ $cnt = count($header);
+ $hdr_s = '';