Fixed generations of secondairy boundaries in case of multidimensional
authorstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 21 Oct 2003 17:41:56 +0000 (17:41 +0000)
committerstekkel <stekkel@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Tue, 21 Oct 2003 17:41:56 +0000 (17:41 +0000)
structures.
All thnx goes to Aaron van Meerten for identifying the bug and all the
testwork.

Modified rfc822 headers to avoid getting hit by spamassassin rules.

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@5995 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/deliver/Deliver.class.php

index 3de308f1166b3c3606db91ddfa3d4338cb7d06e4..ae7b8b57eb175025a5ee7c51c06631c46537842e 100644 (file)
@@ -36,9 +36,18 @@ class Deliver {
     }
 
     function writeBody($message, $stream, &$length_raw, $boundary='') {
+        // calculate boundary in case of multidimensional mime structures
+        if ($boundary && $message->entity_id && count($message->entities)) {
+            if (strpos($boundary,'_part_')) {
+                $boundary = substr($boundary,0,strpos($boundary,'_part_'));
+            }
+            $boundary_new = $boundary . '_part_'.$message->entity_id;
+        } else {
+            $boundary_new = $boundary;
+        }
         if ($boundary && !$message->rfc822_header) {
             $s = '--'.$boundary."\r\n";
-            $s .= $this->prepareMIME_Header($message, $boundary);
+            $s .= $this->prepareMIME_Header($message, $boundary_new);
             $length_raw += strlen($s);
             if ($stream) {
                 $this->preWriteToStream($s);
@@ -46,13 +55,10 @@ class Deliver {
             }
         }
         $this->writeBodyPart($message, $stream, $length_raw);
-        $boundary_depth = substr_count($message->entity_id,'.');
-        if ($boundary_depth) {
-            $boundary .= '_part'.$boundary_depth;
-        }
+        
         $last = false;
         for ($i=0, $entCount=count($message->entities);$i<$entCount;$i++) {
-            $msg = $this->writeBody($message->entities[$i], $stream, $length_raw, $boundary);
+            $msg = $this->writeBody($message->entities[$i], $stream, $length_raw, $boundary_new);
             if ($i == $entCount-1) $last = true;
         }
         if ($boundary && $last) {
@@ -245,7 +251,7 @@ class Deliver {
         $date = date('D, j M Y H:i:s ', mktime()) . $this->timezone();
         /* Create a message-id */
         $message_id = '<' . $REMOTE_PORT . '.' . $REMOTE_ADDR . '.';
-        $message_id .= time() . '.squirrel@' . $SERVER_NAME .'>';
+        $message_id .= time() . '.squirrel@' . $REMOTE_ADDR .'>';
         /* Make an RFC822 Received: line */
         if (isset($REMOTE_HOST)) {
             $received_from = "$REMOTE_HOST ([$REMOTE_ADDR])";
@@ -260,7 +266,7 @@ class Deliver {
         }
         $header = array();
         $header[] = "Received: from $received_from" . $rn;
-        $header[] = "        (SquirrelMail authenticated user $username)" . $rn;
+        $header[] = "        (SquirrelMail authenticated user $username);" . $rn;
         $header[] = "        by $SERVER_NAME with HTTP;" . $rn;
         $header[] = "        $date" . $rn;
         /* Insert the rest of the header fields */
@@ -300,7 +306,9 @@ class Deliver {
             }
         }
         /* Identify SquirrelMail */    
-        $header[] = 'User-Agent: SquirrelMail/' . $version . $rn; 
+        $header[] = 'User-Agent: SquirrelMail/' . $version . $rn;
+       // Spamassassin complains about no X-Mailer in combination with X-Priority
+       $header[] = 'X-Mailer: SquirrelMail/' . $version . $rn; 
         /* Do the MIME-stuff */
         $header[] = 'MIME-Version: 1.0' . $rn;
         $contenttype = 'Content-Type: '. $rfc822_header->content_type->type0 .'/'.
@@ -325,7 +333,7 @@ class Deliver {
         }
         if ($rfc822_header->priority) {
             $prio = $rfc822_header->priority;
-            $header[] = 'X-Priority: '.$prio. $rn;
+            $header[] = 'X-Priority: '. $prio. $rn;
             switch($prio)
             {
             case 1: $header[] = 'Importance: High'. $rn; break;