fix for modified header: $filename = header->getParameter('filename')
[squirrelmail.git] / functions / smtp.php
index 8caa33be4f7387e650f27900927a6f766103a581..9bcda6fcd0ab3051349e19aa3713e5bc4294d9a6 100644 (file)
@@ -158,18 +158,16 @@ function attachFiles ($fp, $session, $rn="\r\n") {
                         if ($rn == "\r\n"){
                             $tmp = str_replace("\n", "\r\n", $tmp);
                         }
-                        /**
-                         * Check if the last line has newline ($rn) in it
-                         * and append if it doesn't.
-                         */
-                        if ($file && feof($fp) && !strstr($tmp, "$rn")){
-                            $tmp .= $rn;
-                        }
                         if ($fp) {
                             fputs($fp, $tmp);
                         }
                         $length += strlen($tmp);
                     }
+                    if (substr($tmp, strlen($tmp) - strlen($rn), strlen($rn)) != $rn) {
+                        if ($fp) {
+                            fputs($fp, $rn);
+                        }
+                    }
                 } else {
                     $header .= "Content-Transfer-Encoding: base64" 
                         . "$rn" . "$rn";
@@ -191,7 +189,7 @@ function attachFiles ($fp, $session, $rn="\r\n") {
 /* Delete files that are uploaded for attaching
  */
 function deleteAttachments($session) {
-    global $username, $attachments, $attachment_dir;
+    global $username, $attachments, $attachment_dir, $data_dir;
     $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
 
     $rem_attachments = array();
@@ -206,6 +204,7 @@ function deleteAttachments($session) {
         }
     }
     $attachments = $rem_attachments;
+    setPref($data_dir, $username, 'attachments', serialize($attachments));
 }
 
 /* Return a nice MIME-boundary