--- smtp.module.original	2007-11-01 16:30:38.000000000 -0600
+++ smtp.module	2007-11-05 18:33:24.000000000 -0700
@@ -179,9 +179,29 @@
         $from = $value; //If a from value was already given then set based on header.
       }
     }
-    else if (strtolower($key) == 'content-type' and strtolower($value) == 'text/html') {
+    else if (strtolower($key) == 'content-type' and ( strpos(strtolower($value), 'text/html') !== false ) ) {
       $mail->IsHTML(TRUE);
     }
+    else if (strtolower($key) == 'content-type' and ( strpos(strtolower($value), 'multipart/mixed') !== false ) ) {
+      //$body passed to smtp should already be formatted. add multipart header and tell phpmailer to leave it alone
+      $mail->AddCustomHeader($key . ": " . $value);
+      $mail->message_type = "pre";
+    }
+    else if (strtolower($key) == 'bcc') {
+      $bccrecipients = split(", ", $value);
+      foreach ($bccrecipients as $bccrecipient) {
+        if ( strpos($bccrecipient, '<') !== false ) {
+          $bccparts = explode(" <", $bccrecipient);
+          $bccname = $bccparts[0];
+          $bccaddr = rtrim($bccparts[1], ">");
+        }
+        else {
+          $bccname = "";
+          $bccaddr = $bccrecipient;
+        }
+        $mail->AddBCC($bccaddr, $bccname);
+      }	
+    }
     else { //Else the header key is not special, just add it.
       $mail->AddCustomHeader($key . ": " . $value); //Add header line.
     }
@@ -214,7 +234,21 @@
 	
 	$mail->From = $from;
 	$mail->FromName = $from_name;
-	$mail->AddAddress($to);
+	
+	$torecipients = split(", ", $to);
+   foreach ($torecipients as $torecipient) {
+     if ( strpos($torecipient, '<') !== false ) {
+       $toparts = explode(" <", $torecipient);
+       $toname = $toparts[0];
+       $toaddr = rtrim($toparts[1], ">");
+     }
+     else {
+       $toname = "";
+       $toaddr = $torecipient;
+     }
+     $mail->AddAddress($toaddr, $toname);
+   }	
+
 	$mail->Subject = $subject;
 	$mail->Body = $body;
 	
@@ -265,6 +299,7 @@
  * Added "var $protocol = '';" to the smtp class variables.
  * After line "if($this->smtp == NULL) { $this->smtp = new SMTP(); }" Added "$this->smtp->protocol = $this->Protocol;"
  * Added "var $Protocol = '';" to the PHPMailer class variables.
+ * Added "pre" message_type to allow pass-through of pre-formated $body 
  **************************************************************************************************/
 
 
@@ -1017,6 +1052,8 @@
            case "alt_attachments":
               $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap);
               break;
+           case "pre":
+              break;
            default:
               $this->Body = $this->WrapText($this->Body, $this->WordWrap);
               break;
@@ -1113,6 +1150,9 @@
                 $result .= $this->HeaderLine("Content-Type", "multipart/alternative;");
                 $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"');
                 break;
+            case "pre":
+                // Content-Type header already added before passing to phpmailer(), leave it alone
+                break;
         }
 
         if($this->Mailer != "mail")
@@ -1181,6 +1221,8 @@
                 
                 $result .= $this->AttachAll();
                 break;
+            case "pre":
+            	$result .= $this->Body;
         }
         if($this->IsError())
             $result = "";
@@ -1222,6 +1264,8 @@
      * @return void
      */
     function SetMessageType() {
+        if ($this->message_type == "pre")
+            return;
         if(count($this->attachment) < 1 && strlen($this->AltBody) < 1)
             $this->message_type = "plain";
         else
