/**
** imap_messages.php
**
- ** This implements functions that manipulate messages
+ ** This implements functions that manipulate messages
+ **
+ ** $Id$
**/
if (!isset($mime_php)) include "../functions/mime.php";
$read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
}
+
+ /******************************************************************************
+ ** Remove specified flag from specified messages
+ ******************************************************************************/
+ function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag) {
+ fputs ($imap_stream, "a001 STORE $start:$end -FLAGS (\\$flag)\r\n");
+ $read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
+ }
+
+
/******************************************************************************
** Returns some general header information -- FROM, DATE, and SUBJECT
******************************************************************************/
class small_header {
- var $from, $subject, $date, $to, $priority, $message_id;
+ var $from = '', $subject = '', $date = '', $to = '',
+ $priority = 0, $message_id = 0, $cc = '';
}
function sqimap_get_small_header ($imap_stream, $id, $sent) {
$from = _("Unknown Sender");
$priority = "0";
$messageid = "<>";
+ $cc = "";
+ $to = "";
+ $date = "";
+ $type[0] = "";
+ $type[1] = "";
$g = 0;
for ($i = 0; $i < count($read); $i++) {
$header = new small_header;
if ($sent == true)
- $header->from = (trim($to) != '')? $to : _('(only Cc/Bcc)');
+ $header->from = (trim($to) != '')? $to : _("(only Cc/Bcc)");
else
$header->from = $from;
$header->size = $size;
$header->type0 = $type[0];
$header->type1 = $type[1];
-
+
return $header;
}
******************************************************************************/
function sqimap_get_message ($imap_stream, $id, $mailbox) {
$header = sqimap_get_message_header($imap_stream, $id, $mailbox);
- $msg = sqimap_get_message_body($imap_stream, &$header);
- return $msg;
+ return sqimap_get_message_body($imap_stream, $header);
}
/******************************************************************************
if (strpos(strtolower(trim($line)), "charset=")) {
$pos = strpos($line, "charset=") + 8;
$charset = trim($line);
- if (strpos($line, " ", $pos) > 0) {
- $charset = substr($charset, $pos, strpos($line, " ", $pos));
+ if (strpos($line, ";", $pos) > 0) {
+ $charset = substr($charset, $pos, strpos($line, ";", $pos)-$pos);
} else {
$charset = substr($charset, $pos);
}
/** FROM **/
else if (strtolower(substr($read[$i], 0, 5)) == "from:") {
$hdr->from = trim(substr($read[$i], 5, strlen($read[$i]) - 6));
- if ($hdr->replyto == "")
+ if (! isset($hdr->replyto) || $hdr->replyto == "")
$hdr->replyto = $hdr->from;
$i++;
}
******************************************************************************/
function sqimap_get_message_body ($imap_stream, &$header) {
$id = $header->id;
- return decodeMime($imap_stream, $body, &$header);
+ return decodeMime($imap_stream, $header);
}