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<BR>";
+ 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;
+ }
+ }
+
?>
echo " <TD><FONT FACE=\"Arial,Helvetica\"><nobr><B><input type=checkbox name=\"msg[$t]\" value=$i></B></nobr></FONT></TD>\n";
echo " <TD><FONT FACE=\"Arial,Helvetica\"><B>$senderName</B></FONT></TD>\n";
echo " <TD><CENTER><B><FONT FACE=\"Arial,Helvetica\">$dateString</FONT></B></CENTER></TD>\n";
- echo " <TD><FONT FACE=\"Arial,Helvetica\"><B><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage\">$subject</A></B></FONT></TD>\n";
+ echo " <TD><FONT FACE=\"Arial,Helvetica\"><B><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage&show_more=0\">$subject</A></B></FONT></TD>\n";
} else {
echo " <TD><FONT FACE=\"Arial,Helvetica\"><nobr><input type=checkbox name=\"msg[$t]\" value=$i></nobr></FONT></TD>\n";
echo " <TD><FONT FACE=\"Arial,Helvetica\">$senderName</FONT></TD>\n";
echo " <TD><FONT FACE=\"Arial,Helvetica\"><CENTER>$dateString</CENTER></FONT></TD>\n";
- echo " <TD><FONT FACE=\"Arial,Helvetica\"><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage\">$subject</A></FONT></TD>\n";
+ echo " <TD><FONT FACE=\"Arial,Helvetica\"><A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$i&sort=$sort&startMessage=$startMessage&show_more=0\">$subject</A></FONT></TD>\n";
}
echo "</TR>\n";
}
echo "<HTML><BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">\n";
$imapConnection = loginToImapServer($username, $key, $imapServerAddress);
- displayPageHeader($mailbox);
- selectMailbox($imapConnection, $mailbox, $numMessages);
+ displayPageHeader("None");
if ($reply_id) {
+ selectMailbox($imapConnection, $mailbox, $numMessages);
$body_ary = fetchBody($imapConnection, $reply_id);
for ($i=0;$i < count($body_ary);$i++) {
$tmp = strip_tags($body_ary[$i]);
$body = "$body> $tmp";
}
} else if ($forward_id) {
+ selectMailbox($imapConnection, $mailbox, $numMessages);
$body_ary = fetchBody($imapConnection, $forward_id);
for ($i=0;$i < count($body_ary);$i++) {
$tmp = strip_tags($body_ary[$i]);
if ($reply_subj)
echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"Re: $reply_subj\"><BR>";
else if ($forward_subj)
- echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"Fwd: $forward_subj\"><BR>";
+ echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60 VALUE=\"[Fwd: $forward_subj]\"><BR>";
else
echo " <INPUT TYPE=TEXT NAME=passed_subject SIZE=60><BR>";
echo " </TD>\n";
displayPageHeader($mailbox);
$body = fetchBody($imapConnection, $passed_id);
getMessageHeaders($imapConnection, $passed_id, $passed_id, $f, $s, $d);
+ getMessageHeadersTo($imapConnection, $passed_id, $passed_id, $t);
$subject = $s[0];
$url_subj = urlencode(trim($subject));
$url_from = trim(decodeEmailAddr($f[0]));
$url_from = urlencode($url_from);
+ $to_left = trim($t[0]);
+ for ($i = 0; $to_left;$i++) {
+ if (strpos($to_left, ",")) {
+ $to_ary[$i] = trim(substr($to_left, 0, strpos($to_left, ",")));
+ $to_left = substr($to_left, strpos($to_left, ",")+1, strlen($to_left));
+ }
+ else {
+ $to_ary[$i] = trim($to_left);
+ $to_left = "";
+ }
+ }
+
+ $i = 0;
+ $to_string = "";
+ while ($i < count($to_ary)) {
+ if ($to_string)
+ $to_string = "$to_string<BR>$to_ary[$i]";
+ else
+ $to_string = "$to_ary[$i]";
+
+ $i++;
+ if (count($to_ary) > 1) {
+ if ($show_more == false) {
+ if ($i == 1) {
+ $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1\">more</A>)";
+ $i = count($to_ary);
+ }
+ } else if ($i == 1) {
+ $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0\">less</A>)";
+ }
+ }
+ }
+
echo "<BR>";
echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
echo " <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
echo " <FONT FACE=\"Arial,Helvetica\"><B>$date</B></FONT>\n";
echo " </TD>\n";
echo " </TR>\n";
+ /** to **/
+ echo " <TR>\n";
+ echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
+ echo " <FONT FACE=\"Arial,Helvetica\">To:</FONT>\n";
+ echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
+ echo " <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
+ echo " </TD>\n";
+ echo " </TR>\n";
echo " </TABLE></TD></TR>\n";