From e1debf92f73fab82a01e0e90a4f537b28f22841f Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sat, 13 Jan 2007 18:07:12 +0000 Subject: [PATCH] Implements the mail sending in the mbox module git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@162 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/banana.inc.php.in | 4 +++- banana/mbox.inc.php | 14 +++++++++++++- banana/mimepart.inc.php | 11 ++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index 2dcf55a..0da49bd 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -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); } diff --git a/banana/mbox.inc.php b/banana/mbox.inc.php index 93ffff5..a5bfdc7 100644 --- a/banana/mbox.inc.php +++ b/banana/mbox.inc.php @@ -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 diff --git a/banana/mimepart.inc.php b/banana/mimepart.inc.php index 9f039eb..26cb31a 100644 --- a/banana/mimepart.inc.php +++ b/banana/mimepart.inc.php @@ -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; } -- 2.1.4