X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fmailbox.php;h=31eb5542c7b31d0d2c2df53da0c8fd2ca299766b;hp=9092744d48cad7db4c440c5f72d202217c533c7d;hb=2844086da1696de4ab45981b0d749d57502781d0;hpb=31f3d7c03a7c155d48a955b4beb15105ba154086 diff --git a/functions/mailbox.php b/functions/mailbox.php index 9092744d..31eb5542 100644 --- a/functions/mailbox.php +++ b/functions/mailbox.php @@ -316,4 +316,42 @@ return $line; } + + function getMessageHeadersTo($imapConnection, $start, $end, &$to) { + $rel_start = $start; + if (($start > $end) || ($start < 1)) { + echo "Error in message header fetching. Start message: $start, End message: $end
"; + exit; + } + + $pos = 0; + while ($rel_start <= $end) { + if ($end - $rel_start > 50) { + $rel_end = $rel_start + 49; + } else { + $rel_end = $end; + } + fputs($imapConnection, "messageFetch FETCH $rel_start:$rel_end RFC822.HEADER.LINES (To)\n"); + $read = fgets($imapConnection, 1024); + + while ((substr($read, 0, 15) != "messageFetch OK") && (substr($read, 0, 16) != "messageFetch BAD")) { + if (substr($read, 0, 3) == "To:") { + $read = ereg_replace("<", "<", $read); + $read = ereg_replace(">", ">", $read); + $to[$pos] = substr($read, 3, strlen($read)); + if (strlen(Chop($to[$pos])) == 0) + $to[$pos] = "Unknown Recipients"; + } + else if (substr($read, 0, 1) == ")") { + if ($subject[$pos] == "") + $subject[$pos] = "Unknown Recipients"; + $pos++; + } + + $read = fgets($imapConnection, 1024); + } + $rel_start = $rel_start + 50; + } + } + ?>