sent shows "to" instead of "from"
[squirrelmail.git] / functions / imap_messages.php
index fe3255fa3abb1e3eb65574dcceb68d444d6d1ba2..cdd240a82b6642fd3d652a5b6a946ac9de4df69b 100755 (executable)
@@ -1,4 +1,4 @@
-<?
+<?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));