From bde645fdf1fef55ba8da8657918363fc237fb969 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 05 Feb 2006 11:14:56 -0500
Subject: [PATCH] Added patches for BCC headers

---
 program/steps/mail/func.inc     |    4 ++--
 program/lib/imap.inc            |    4 +++-
 program/steps/mail/sendmail.inc |    8 ++++++--
 program/include/rcube_imap.inc  |    2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/program/include/rcube_imap.inc b/program/include/rcube_imap.inc
index cb6b409..400d0c0 100644
--- a/program/include/rcube_imap.inc
+++ b/program/include/rcube_imap.inc
@@ -766,7 +766,7 @@
     $mailbox = $mbox ? $this->_mod_mailbox($mbox) : $this->mailbox;
 
     // get cached headers
-    if ($headers = $this->get_cached_message($mailbox.'.msg', $uid))
+    if ($is_uid && ($headers = $this->get_cached_message($mailbox.'.msg', $id)))
       return $headers;
 
     $msg_id = $is_uid ? $this->_uid2id($id) : $id;
diff --git a/program/lib/imap.inc b/program/lib/imap.inc
index e03abe4..48b2cd1 100644
--- a/program/lib/imap.inc
+++ b/program/lib/imap.inc
@@ -36,6 +36,7 @@
 		- Parse charset from content-type in iil_C_FetchHeaders()
 		- Enhanced heaer sorting
 		- Pass message as reference in iil_C_Append (to save memory)
+		- Added BCC to the list of headers to fetch in iil_C_FetchHeaders()
 		- Removed some debuggers (echo ...)
 
 ********************************************************/
@@ -1207,7 +1208,7 @@
 
 	/* FETCH date,from,subject headers */
 	$key="fh".($c++);
-	$request=$key." FETCH $message_set (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID)])\r\n";
+	$request=$key." FETCH $message_set (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC BCC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID)])\r\n";
 
 	if (!fputs($fp, $request)) return false;
 	do{
@@ -1258,6 +1259,7 @@
 			$result[$id]->subject = str_replace("\n", "", $headers["subject"]);
 			$result[$id]->replyto = str_replace("\n", " ", $headers["reply-to"]);
 			$result[$id]->cc = str_replace("\n", " ", $headers["cc"]);
+			$result[$id]->bcc = str_replace("\n", " ", $headers["bcc"]);
 			$result[$id]->encoding = str_replace("\n", " ", $headers["content-transfer-encoding"]);
 			$result[$id]->ctype = str_replace("\n", " ", $headers["content-type"]);
 			$result[$id]->in_reply_to = ereg_replace("[\n<>]",'', $headers['in-reply-to']);
diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc
index d089dd2..926121d 100644
--- a/program/steps/mail/func.inc
+++ b/program/steps/mail/func.inc
@@ -940,7 +940,7 @@
   $out = '<table' . $attrib_str . ">\n";
 
   // show these headers
-  $standard_headers = array('subject', 'from', 'organization', 'to', 'cc', 'reply-to', 'date');
+  $standard_headers = array('subject', 'from', 'organization', 'to', 'cc', 'bcc', 'reply-to', 'date');
   
   foreach ($standard_headers as $hkey)
     {
@@ -949,7 +949,7 @@
 
     if ($hkey=='date' && !empty($headers[$hkey]))
       $header_value = format_date(strtotime($headers[$hkey]));
-    else if (in_array($hkey, array('from', 'to', 'cc', 'reply-to')))
+    else if (in_array($hkey, array('from', 'to', 'cc', 'bcc', 'reply-to')))
       $header_value = rep_specialchars_output(rcmail_address_string($IMAP->decode_header($headers[$hkey]), NULL, $attrib['addicon']));
     else
       $header_value = rep_specialchars_output($IMAP->decode_header($headers[$hkey]), '', 'all');
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 9d93034..0ec19a9 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -181,7 +181,7 @@
 
 
 // encoding settings for mail composing
-$message_param = array('text_encoding' => '7bit',
+$message_param = array('text_encoding' => '8bit',
                        'html_encoding' => 'quoted-printable',
                        'head_encoding' => 'quoted-printable',
                        'head_charset'  => $message_charset,
@@ -204,8 +204,12 @@
   if (strlen($headers['Bcc']))
     $a_recipients[] = $headers['Bcc'];
 
+  // clean Bcc from header for recipients
+  $send_headers = $headers;
+  unset($send_headers['Bcc']);
+
   // generate message headers
-  $header_str = $MAIL_MIME->txtHeaders($headers);
+  $header_str = $MAIL_MIME->txtHeaders($send_headers);
 
   // send message
   $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body);

--
Gitblit v1.9.1