2 include("../config/config.php");
3 include("../functions/strings.php");
4 include("../functions/page_header.php");
5 include("../functions/imap.php");
6 include("../functions/mime.php");
7 include("../functions/mailbox.php");
8 include("../functions/date.php");
10 $imapConnection = loginToImapServer($username, $key, $imapServerAddress);
11 selectMailbox($imapConnection, $mailbox, $numMessages);
13 // $message contains all information about the message
14 // including header and body
15 $message = fetchMessage($imapConnection, $passed_id);
18 echo "<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"" . $message["HEADER"]["TYPE"][0] . "/" . $message["HEADER"]["TYPE"][1] . "; charset=" . $message["HEADER"]["CHARSET"] . "\">";
19 echo "<BODY TEXT=\"#000000\" BGCOLOR=\"#FFFFFF\" LINK=\"#0000EE\" VLINK=\"#0000EE\" ALINK=\"#0000EE\">\n";
20 displayPageHeader($mailbox);
22 /** translate the subject and mailbox into url-able text **/
23 $url_subj = urlencode(trim($message["HEADER"]["SUBJECT"]));
24 $urlMailbox = urlencode($mailbox);
25 $url_from = urlencode($message["HEADER"]["FROM"]);
27 $dateString = getLongDateString($message["HEADER"]["DATE"]);
29 /** FORMAT THE TO STRING **/
32 $to_ary = $message["HEADER"]["TO"];
33 while ($i < count($to_ary)) {
34 $to_ary[$i] = htmlspecialchars($to_ary[$i]);
36 $to_string = "$to_string<BR>$to_ary[$i]";
38 $to_string = "$to_ary[$i]";
41 if (count($to_ary) > 1) {
42 if ($show_more == false) {
44 $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">more</A>)";
48 $to_string = "$to_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">less</A>)";
53 /** FORMAT THE CC STRING **/
56 $cc_ary = $message["HEADER"]["CC"];
57 while ($i < count($cc_ary)) {
58 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
60 $cc_string = "$cc_string<BR>$cc_ary[$i]";
62 $cc_string = "$cc_ary[$i]";
65 if (count($cc_ary) > 1) {
66 if ($show_more_cc == false) {
68 $cc_string = "$cc_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">more</A>)";
72 $cc_string = "$cc_string (<A HREF=\"read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">less</A>)";
77 /** make sure everything will display in HTML format **/
78 $from_name = htmlspecialchars($message["HEADER"]["FROM"]);
79 $subject = htmlspecialchars($message["HEADER"]["SUBJECT"]);
82 echo "<TABLE COLS=1 WIDTH=95% BORDER=0 ALIGN=CENTER CELLPADDING=2>\n";
83 echo " <TR><TD BGCOLOR=DCDCDC WIDTH=100%>";
84 echo " <TABLE WIDTH=100% BORDER=0 COLS=2>";
86 echo " <TD ALIGN=LEFT WIDTH=50%>";
87 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
88 echo " <A HREF=\"right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">Message List</A> ";
89 echo " <A HREF=\"delete_message.php?mailbox=$urlMailbox&message=$passed_id&sort=$sort&startMessage=1\">Delete</A> ";
91 echo " </TD><TD WIDTH=50% ALIGN=RIGHT>";
92 echo " <FONT FACE=\"Arial,Helvetica\" SIZE=2>";
93 echo " <A HREF=\"compose.php?forward_id=$passed_id&forward_subj=$url_subj&mailbox=$urlMailbox\">Forward</A> ";
94 echo " <A HREF=\"compose.php?send_to=$url_from&reply_subj=$url_subj&reply_id=$passed_id&mailbox=$urlMailbox\">Reply</A> ";
100 echo " <TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
101 echo " <TABLE COLS=2 WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=2>\n";
104 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
105 echo " <FONT FACE=\"Arial,Helvetica\">Subject:</FONT>\n";
106 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
107 echo " <FONT FACE=\"Arial,Helvetica\"><B>$subject</B></FONT>\n";
112 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
113 echo " <FONT FACE=\"Arial,Helvetica\">From:</FONT>\n";
114 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
115 echo " <FONT FACE=\"Arial,Helvetica\"><B>$from_name</B></FONT>\n";
120 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT>\n";
121 echo " <FONT FACE=\"Arial,Helvetica\">Date:</FONT>\n";
122 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85%>\n";
123 echo " <FONT FACE=\"Arial,Helvetica\"><B>$dateString</B></FONT>\n";
128 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
129 echo " <FONT FACE=\"Arial,Helvetica\">To:</FONT>\n";
130 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
131 echo " <FONT FACE=\"Arial,Helvetica\"><B>$to_string</B></FONT>\n";
135 if ($message["HEADER"]["CC"][0]) {
137 echo " <TD BGCOLOR=FFFFFF WIDTH=15% ALIGN=RIGHT VALIGN=TOP>\n";
138 echo " <FONT FACE=\"Arial,Helvetica\">Cc:</FONT>\n";
139 echo " </TD><TD BGCOLOR=FFFFFF WIDTH=85% VALIGN=TOP>\n";
140 echo " <FONT FACE=\"Arial,Helvetica\"><B>$cc_string</B></FONT>\n";
144 echo " </TABLE></TD></TR>\n";
146 echo " <TR><TD BGCOLOR=FFFFFF WIDTH=100%>\n";
147 $body = formatBody($message);
148 for ($i = 0; $i < count($body); $i++
) {
152 /* if (count($message["ENTITIES"]) > 1) {
153 echo "</TD></TR><TR><TD BGCOLOR=DCDCDC><CENTER><B><FONT COLOR=DD0000>This is a multipart MIME encoded message.</FONT></B></CENTER></TD></TR><TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
159 while ($i < count($message["ENTITIES"])) {
161 echo "</TD></TR><TR><TD BGCOLOR=DCDCDC><CENTER>Part $b</CENTER></TD></TR><TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
162 for ($p = 0; $p < count($message["ENTITIES"][$i][0]["BODY"]); $p++) {
163 echo $message["ENTITIES"][$i][0]["BODY"][$p];
168 echo "</TD></TR><TR><TD BGCOLOR=DCDCDC><CENTER><B><FONT COLOR=DD0000>This is a single part MIME encoded message.</FONT></B></CENTER></TD></TR><TR><TD BGCOLOR=FFFFFF WIDTH=100%>";
169 for ($p = 0; $p < count($message["ENTITIES"][0]["BODY"]); $p++) {
170 echo $message["ENTITIES"][0]["BODY"][$p];
174 echo " <BR></TD></TR>\n";
175 echo " <TR><TD BGCOLOR=DCDCDC> </TD></TR>";