-<?
+<?php
/**
** imap_messages.php
**
/******************************************************************************
** Returns some general header information -- FROM, DATE, and SUBJECT
******************************************************************************/
- function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date) {
- fputs ($imap_stream, "a001 FETCH $id:$id RFC822.HEADER.LINES (From Subject Date)\r\n");
+ function sqimap_get_small_header ($imap_stream, $id, &$from, &$subject, &$date, $sent) {
+ //fputs ($imap_stream, "a001 FETCH $id BODY[HEADER.FIELDS (DATE FROM SUBJECT)]\r\n");
+ fputs ($imap_stream, "a001 FETCH $id RFC822.HEADER\r\n");
$read = sqimap_read_data ($imap_stream, "a001", true, $response, $message);
+ $subject = _("(no subject)");
+ $from = _("Unknown Sender");
for ($i = 0; $i < count($read); $i++) {
- if (strtolower(substr($read[$i], 0, 5)) == "from:") {
- $from = sqimap_find_displayable_name(substr($read[$i], 5));
- } else if (strtolower(substr($read[$i], 0, 5)) == "date:") {
+ if ($sent == true) {
+ if (strtolower(substr($read[$i], 0, 3)) == "to:")
+ $from = sqimap_find_displayable_name(substr($read[$i], 3));
+ } else {
+ if (strtolower(substr($read[$i], 0, 5)) == "from:")
+ $from = sqimap_find_displayable_name(substr($read[$i], 5));
+ }
+
+ if (strtolower(substr($read[$i], 0, 5)) == "date:") {
$date = substr($read[$i], 5);
} else if (strtolower(substr($read[$i], 0, 8)) == "subject:") {
$subject = htmlspecialchars(substr($read[$i], 8));
}
/** Detect the boundary of a multipart message **/
- if (strpos(strtolower(trim($line)), "boundary=")) {
- $pos = strpos(strtolower($line), "boundary=") + 9;
- $bound = trim($line);
- if (strpos($line, " ", $pos) > 0) {
- $bound = substr($bound, $pos, strpos($line, " ", $pos));
- } else {
- $bound = substr($bound, $pos);
- }
- $bound = str_replace("\"", "", $bound);
- $header["BOUNDARY"] = $bound;
+ if (eregi("boundary=\"([^\"]+)\"", $line, $regs)) {
+ $header["BOUNDARY"] = $regs[1];
}
/** Detect the charset **/