From 90fe6cbc357d11e044f9a3e6c0be9d81b3c2bdf7 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Mon, 25 Jan 2010 07:34:51 -0500
Subject: [PATCH] - Mail_MIME update

---
 program/lib/Mail/mimePart.php |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/program/lib/Mail/mimePart.php b/program/lib/Mail/mimePart.php
index 644b2b6..ce37deb 100644
--- a/program/lib/Mail/mimePart.php
+++ b/program/lib/Mail/mimePart.php
@@ -330,15 +330,16 @@
      * Encodes and saves the email into file. File must exist.
      * Data will be appended to the file.
      *
-     * @param string $filename Output file location
-     * @param string $boundary Pre-defined boundary string
+     * @param string  $filename  Output file location
+     * @param string  $boundary  Pre-defined boundary string
+     * @param boolean $skip_head True if you don't want to save headers
      *
      * @return array An associative array containing message headers
      *               or PEAR error object
      * @access public
      * @since 1.6.0
      */
-    function encodeToFile($filename, $boundary=null)
+    function encodeToFile($filename, $boundary=null, $skip_head=false)
     {
         if (file_exists($filename) && !is_writable($filename)) {
             $err = PEAR::raiseError('File is not writeable: ' . $filename);
@@ -355,7 +356,7 @@
             @ini_set('magic_quotes_runtime', 0);
         }
 
-        $res = $this->_encodePartToFile($fh, $boundary);
+        $res = $this->_encodePartToFile($fh, $boundary, $skip_head);
 
         fclose($fh);
 
@@ -369,13 +370,14 @@
     /**
      * Encodes given email part into file
      *
-     * @param string $fh       Output file handle
-     * @param string $boundary Pre-defined boundary string
+     * @param string  $fh        Output file handle
+     * @param string  $boundary  Pre-defined boundary string
+     * @param boolean $skip_head True if you don't want to save headers
      *
      * @return array True on sucess or PEAR error object
      * @access private
      */
-    function _encodePartToFile($fh, $boundary=null)
+    function _encodePartToFile($fh, $boundary=null, $skip_head=false)
     {
         $eol = $this->_eol;
 
@@ -384,25 +386,31 @@
             $this->_headers['Content-Type'] .= ";$eol boundary=\"$boundary\"";
         }
 
-        foreach ($this->_headers as $key => $value) {
-            fwrite($fh, $key . ': ' . $value . $eol);
+        if (!$skip_head) {
+            foreach ($this->_headers as $key => $value) {
+                fwrite($fh, $key . ': ' . $value . $eol);
+            }
+            $f_eol = $eol;
+        } else {
+            $f_eol = '';
         }
 
         if (count($this->_subparts)) {
             for ($i = 0; $i < count($this->_subparts); $i++) {
-                fwrite($fh, $eol . '--' . $boundary . $eol);
+                fwrite($fh, $f_eol . '--' . $boundary . $eol);
                 $res = $this->_subparts[$i]->_encodePartToFile($fh);
                 if (PEAR::isError($res)) {
                     return $res;
                 }
+                $f_eol = $eol;
             }
 
             fwrite($fh, $eol . '--' . $boundary . '--' . $eol);
 
         } else if ($this->_body) {
-            fwrite($fh, $eol . $this->_getEncodedData($this->_body, $this->_encoding));
+            fwrite($fh, $f_eol . $this->_getEncodedData($this->_body, $this->_encoding));
         } else if ($this->_body_file) {
-            fwrite($fh, $eol);
+            fwrite($fh, $f_eol);
             $res = $this->_getEncodedDataFromFile(
                 $this->_body_file, $this->_encoding, $fh
             );

--
Gitblit v1.9.1