Implements the mail sending in the mbox module
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 13 Jan 2007 18:07:12 +0000 (18:07 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:17 +0000 (00:35 +0100)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@162 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/banana.inc.php.in
banana/mbox.inc.php
banana/mimepart.inc.php

index 2dcf55a..0da49bd 100644 (file)
@@ -443,11 +443,13 @@ class Banana
         if (!Banana::$spool || Banana::$spool->group != $group) {
             if ($group == @$_SESSION['banana_group'] && isset($_SESSION['banana_spool'])) {
                 Banana::$spool = unserialize($_SESSION['banana_spool']);
+                $clean = @(Banana::$profile['lastnews'] != $_SESSION['banana_lastnews']);
             }
-            BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup']);
+            BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup'] || $clean);
             $_SESSION['banana_group'] = $group;
             if (!Banana::$profile['display']) {
                 $_SESSION['banana_spool'] = serialize(Banana::$spool);
+                $_SESSION['banana_lastnews'] = Banana::$profile['lastnews'];
             }
             Banana::$spool->setMode(Banana::$profile['display'] ? Banana::SPOOL_UNREAD : Banana::SPOOL_ALL);
         }
index 93ffff5..a5bfdc7 100644 (file)
@@ -232,7 +232,19 @@ class BananaMBox implements BananaProtocoleInterface
      */
     public function send(BananaMessage &$message)
     {
-        return true;
+        $headers = $message->getHeaders();
+        $to      = $headers['To'];
+        $subject = $headers['Subject'];
+        unset($headers['To']);
+        unset($headers['Subject']);
+        $hdrs    = '';
+        foreach ($headers as $key=>$value) {
+            if (!empty($value)) {
+                $hdrs .= "$key: $value\r\n";
+            }    
+        }
+        $body = $message->get(false);
+        return mail($to, $subject, $body, $hdrs);
     }
 
     /** Cancel a message
index 9f039eb..26cb31a 100644 (file)
@@ -388,8 +388,13 @@ class BananaMimePart
         $content = "";
         if ($with_headers) {
             foreach ($this->getHeaders() as $key => $value) {
-                $content .= "$key: $value\n"; 
-            }   
+                $line = "$key: $value"; 
+                $line = explode("\n", wordwrap($line, Banana::$msgshow_wrap));
+                for ($i = 1 ; $i < count($line) ; $i++) {
+                    $line[$i] = "\t" . $line[$i];
+                }
+                $content .= implode("\n", $line) . "\n";
+            } 
             $content .= "\n";
         } 
         if ($this->isType('multipart')) {
@@ -399,7 +404,7 @@ class BananaMimePart
             }
             $content .= "\n--{$this->boundary}--";
         } else {
-            $content .= $this->body;
+            $content .= banana_wordwrap($this->body);
         }
         return $content;
     }