6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file is used for reading the msgs array and displaying
10 * the resulting emails in the right frame.
15 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/mime.php');
18 require_once('../functions/date.php');
19 require_once('../functions/url_parser.php');
20 require_once('../functions/smtp.php');
23 * Given an IMAP message id number, this will look it up in the cached
24 * and sorted msgs array and return the index. Used for finding the next
25 * and previous messages.
27 * @return the index of the next valid message from the array
29 function findNextMessage() {
30 global $msort, $currentArrayIndex, $msgs, $sort,
31 $thread_sort_messages, $allow_server_sort,
33 if (!is_array($server_sort_array)) {
34 $thread_sort_messages = 0;
35 $allow_server_sort = FALSE;
38 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
39 reset($server_sort_array);
40 while(list($key, $value) = each ($server_sort_array)) {
41 if ($currentArrayIndex == $value) {
42 if ($key == (count($server_sort_array) - 1)) {
46 $result = $server_sort_array[$key +
1];
51 elseif ($sort == 6 && $allow_server_sort != TRUE &&
52 $thread_sort_messages != 1) {
53 if ($currentArrayIndex != 1) {
54 $result = $currentArrayIndex - 1;
57 elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) {
58 if (!is_array($msort)) {
61 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
62 if ($currentArrayIndex == $msgs[$key]['ID']) {
66 $result = $msgs[$key]['ID'];
76 * Removes just one address from the list of addresses.
78 * @param &$addr_list a by-ref array of addresses
79 * @param $addr an address to remove
80 * @return void, since it operates on a by-ref param
82 function RemoveAddress(&$addr_list, $addr) {
84 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
85 unset($addr_list[$key_to_delete]);
90 /** returns the index of the previous message from the array. */
91 function findPreviousMessage() {
92 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
93 $mailbox, $data_dir, $username, $thread_sort_messages,
94 $allow_server_sort, $server_sort_array;
96 if (!is_array($server_sort_array)) {
97 $thread_sort_messages = 0;
98 $allow_server_sort = FALSE;
100 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
101 reset($server_sort_array);
102 while(list($key, $value) = each ($server_sort_array)) {
103 if ($currentArrayIndex == $value) {
108 $result = $server_sort_array[$key -1];
113 elseif ($sort == 6 && $allow_server_sort != TRUE &&
114 $thread_sort_messages != 1) {
115 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
116 if ($currentArrayIndex != $numMessages) {
117 $result = $currentArrayIndex +
1;
120 elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
121 if (!is_array($msort)) {
124 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
125 if ($currentArrayIndex == $msgs[$key]['ID']) {
129 $result = $msgs[$key]['ID'];
139 * Displays a link to a page where the message is displayed more
140 * "printer friendly".
142 function printer_friendly_link() {
143 global $passed_id, $mailbox, $ent_num, $color,
147 if (strlen(trim($mailbox)) < 1) {
151 $params = '?passed_ent_id=' . $ent_num .
152 '&mailbox=' . urlencode($mailbox) .
153 '&passed_id=' . $passed_id;
155 $print_text = _("View Printable Version");
157 if (!$pf_subtle_link) {
158 /* The link is large, on the bottom of the header panel. */
159 $result = '<tr bgcolor="' . $color[0] . '">' .
160 '<td class="medText" align="right" valign="top">' .
162 '</td><td class="medText" valign="top" colspan="2">'."\n";
164 /* The link is subtle, below "view full header". */
168 /* Output the link. */
169 if ($javascript_on) {
170 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
172 " function printFormat() {\n" .
173 ' window.open("../src/printer_friendly_main.php' .
174 $params . '","Print","width=800,height=600");' . "\n".
178 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
180 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
181 "$params\">$print_text</A>\n";
184 if (!$pf_subtle_link) {
185 /* The link is large, on the bottom of the header panel. */
186 $result .= '</td></tr>' . "\n";
192 function ServerMDNSupport( $read ) {
193 /* escaping $ doesn't work -> \x36 */
194 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
198 function SendMDN ( $recipient , $sender) {
199 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
200 $version, $attachments, $identity, $data_dir, $passed_id;
202 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
203 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
207 $senton = getLongDateString( $header->date
);
208 $to_array = $header->to
;
210 foreach ($to_array as $line) {
214 $subject = $header->subject
;
215 $now = getLongDateString( time() );
219 $body = _("Your message") . "\r\n\r\n" .
220 "\t" . _("To:") . ' ' . $to . "\r\n" .
221 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
222 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
224 sprintf( _("Was displayed on %s"), $now );
228 $original_recipient = $to;
229 $original_message_id = $header->message_id
;
231 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
232 if ($original_recipient != '') {
233 $part2 .= "Original-Recipient : $original_recipient\r\n";
235 $final_recipient = $sender;
236 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
237 "Original-Message-ID : $original_message_id\r\n" .
238 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
241 $localfilename = GenerateRandomString(32, 'FILE', 7);
242 $full_localfilename = "$hashed_attachment_dir/$localfilename";
244 $fp = fopen( $full_localfilename, 'w');
245 fwrite ($fp, $part2);
248 $newAttachment = array();
249 $newAttachment['localfilename'] = $localfilename;
250 $newAttachment['type'] = "message/disposition-notification";
251 $newAttachment['session']=-1;
252 $attachments[] = $newAttachment;
253 $MDN_to = trim($recipient);
256 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
257 $body, $reply_id, True, 3, -1) );
261 function ToggleMDNflag ( $set ) {
262 global $imapConnection, $passed_id, $mailbox;
263 sqimap_mailbox_select($imapConnection, $mailbox);
265 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
266 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
270 function ClearAttachments() {
271 global $username, $attachments, $attachment_dir;
273 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
275 $rem_attachments = array();
276 foreach ($attachments as $info) {
277 if ($info['session'] == -1) {
278 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
279 if (file_exists($attached_file)) {
280 unlink($attached_file);
283 $rem_attachments[] = $info;
286 $attachments = $rem_attachments;
289 function formatRecipientString($recipients, $item ) {
290 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
291 $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
296 if (isset ($recipients[0]) && trim($recipients[0])) {
302 $show = "&show_more=1&show_more_cc=$show_more_cc&".
303 "show_more_bcc=$show_more_bcc";
304 $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
305 "show_more_bcc=$show_more_bcc";
308 $show = "&show_more=$show_more&show_more_cc=1&".
309 "show_more_bcc=$show_more_bcc";
310 $show_n = "&show_more=$show_more&show_more_cc=0&".
311 "show_more_bcc=$show_more_bcc";
312 $show_more = $show_more_cc;
315 $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
316 "&show_more_bcc=1";
317 $show_n = "&show_more=$show_more&show_more_cc=".
318 "$show_more_cc&show_more_bcc=0";
319 $show_more = $show_more_bcc;
325 while ($i < count($ary)) {
326 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
327 $url_string .= $ary[$i];
329 $string = "$string<BR>$ary[$i]";
331 $string = "$ary[$i]";
335 if (count($ary) > 1) {
336 if ($show_more == false) {
338 /* From a search... */
339 $string .= ' (<A HREF="' . $base_uri .
340 "src/read_body.php?mailbox=$urlMailbox&".
341 "passed_id=$passed_id&";
342 if (isset($where) && isset($what)) {
343 $string .= 'what=' . urlencode($what).
344 "&where=".urlencode($where).
345 "$show\">$echo_more</A>)";
347 $string .= "sort=$sort&startMessage=".
348 "$startMessage"."$show\">$echo_more</A>)";
352 } else if ($i == 1) {
353 /* From a search... */
354 $string .= ' (<A HREF="' . $base_uri .
355 "src/read_body.php?mailbox=$urlMailbox&".
356 "passed_id=$passed_id&";
357 if (isset($where) && isset($what)) {
358 $string .= 'what=' . urlencode($what).
359 "&where=".urlencode($where).
360 "$show_n\">$echo_less</A>)";
362 $string .= "sort=$sort&startMessage=$startMessage".
363 "$show_n\">$echo_less</A>)";
372 $url_string = urlencode($url_string);
374 $result['str'] = $string;
375 $result['url_str'] = $url_string;
382 * Main of read_boby.php --------------------------------------------------
391 if (isset($mailbox)){
392 $mailbox = urldecode( $mailbox );
394 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
396 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
401 * The following code sets necesarry stuff for the MDN thing
403 if($default_use_mdn &&
404 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
405 $default_use_mdn))) {
407 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
408 $flags = sqimap_get_flags ($imapConnection, $passed_id);
409 $FirstTimeSee = !(in_array( 'Seen', $flags ));
412 displayPageHeader($color, $mailbox);
416 * The following code shows the header of the message and then exit
418 if (isset($view_hdr)) {
419 $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
423 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
424 ' ALIGN="CENTER">' . "\n" .
425 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
426 _("Viewing Full Header") . '</B> - '.
427 '<a href="' . $base_uri . 'src/read_body.php?mailbox='.
429 if (isset($where) && isset($what)) {
430 // Got here from a search
431 echo "&passed_id=$passed_id&where=".urlencode($where).
432 "&what=".urlencode($what).'">';
434 echo "&passed_id=$passed_id&startMessage=$startMessage".
435 "&show_more=$show_more\">";
437 echo _("View message") . "</a></b></td></tr></table>\n".
438 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
443 for ($i=1; $i < count($read); $i++
) {
444 $line = htmlspecialchars($read[$i]);
445 if (eregi("^>", $line)) {
447 $first[$i] = ' ';
449 } else if (eregi("^[ |\t]", $line)) {
452 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
453 $first[$i] = $regs[1] . ':';
454 $second[$i] = $regs[2];
457 $second[$i] = trim($line);
461 for ($i=0; $i < count($second); $i = $j) {
462 if (isset($first[$i])) {
465 if (isset($second[$i])) {
466 $s = nl2br($second[$i]);
469 while (($first[$j] == '') && ($j < count($first))) {
470 $s .= ' ' . nl2br($second[$j]);
475 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
478 echo "</td></tr></table>\n" .
480 sqimap_logout($imapConnection);
485 $currentArrayIndex = $passed_id;
487 $currentArrayIndex = -1;
490 for ($i = 0; $i < count($msgs); $i++
) {
491 if ($msgs[$i]['ID'] == $passed_id) {
492 $msgs[$i]['FLAG_SEEN'] = true;
497 * $message contains all information about the message
498 * including header and body
500 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
502 /** translate the subject and mailbox into url-able text **/
503 $url_subj = urlencode(trim($message->header
->subject
));
504 $urlMailbox = urlencode($mailbox);
506 if (isset($message->header
->replyto
)) {
507 $url_replyto = urlencode($message->header
->replyto
);
510 $url_replytoall = $url_replyto;
513 * If we are replying to all, then find all other addresses and
514 * add them to the list. Remove duplicates.
515 * This is somewhat messy, so I'll explain:
516 * 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
518 $url_replytoall_extra_addrs = array_merge(
519 array($message->header
->from
),
520 $message->header
->to
,
525 * 2) Make one big string out of them
527 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
530 * 3) Parse that into an array of addresses
532 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
535 * 4) Make them unique -- weed out duplicates
536 * (Coded for PHP 4.0.0)
538 $url_replytoall_extra_addrs =
539 array_keys(array_flip($url_replytoall_extra_addrs));
542 * 5) Remove the addresses we'll be sending the message 'to'
544 $url_replytoall_avoid_addrs = '';
545 if (isset($message->header
->replyto
)) {
546 $url_replytoall_avoid_addrs = $message->header
->replyto
;
549 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
550 foreach ($url_replytoall_avoid_addrs as $addr) {
551 RemoveAddress($url_replytoall_extra_addrs, $addr);
555 * 6) Remove our identities from the CC list (they still can be in the
556 * TO list) only if $include_self_reply_all is turned off
558 if (!$include_self_reply_all) {
559 RemoveAddress($url_replytoall_extra_addrs,
560 getPref($data_dir, $username, 'email_address'));
561 $idents = getPref($data_dir, $username, 'identities');
562 if ($idents != '' && $idents > 1) {
563 for ($i = 1; $i < $idents; $i ++
) {
564 $cur_email_address = getPref($data_dir, $username,
565 'email_address' . $i);
566 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
572 * 7) Smoosh back into one nice line
574 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
579 $url_replytoallcc = urlencode($url_replytoallcc);
581 $dateString = getLongDateString($message->header
->date
);
584 * What do we reply to -- text only, if possible
591 if ($message->header->type0 == 'multipart' && $message->header->type1 == 'digest') {
592 listEntities($message);
593 for ($i = 0; $i < count($message->entities); $i++) {
595 $msg = $message->entities[$i];
596 $body .= $msg->header->type0 .'/'.$msg->header->type1 .'<BR>';
598 $msg->header->type0 = 'message';
599 $msg->header->type1 = 'rfc822';
600 $ent_ar = findDisplayEntity($msg, false);
601 for ($i = 0; $i < count($ent_ar); $i++) {
602 $body .= formatBody($imapConnection, $msg, $color, $wrap_at, $ent_ar[$i]);
608 $ent_ar = findDisplayEntity($message, false);
610 for ($i = 0; $i < count($ent_ar); $i++
) {
611 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i]);
617 /* first step in displaying multiple entities */
618 $ent_ar = findDisplayEntity($message,true);
620 $ent_num = $ent_num_ar[0];
621 for ($i = 1 ; $i < count($ent_ar); $i++
) {
622 $ent_num .= '_'.$ent_num_ar[$i];
624 /** TEXT STRINGS DEFINITIONS **/
625 $echo_more = _("more");
626 $echo_less = _("less");
628 if (!isset($show_more_cc)) {
629 $show_more_cc = FALSE;
632 if (!isset($show_more_bcc)) {
633 $show_more_bcc = FALSE;
636 /** FORMAT THE TO STRING **/
637 $to = formatRecipientString($message->header
->to
, "to");
638 $to_string = $to['str'];
639 $url_to_string = $to['url_str'];
642 /** FORMAT THE CC STRING **/
644 $cc = formatRecipientString($message->header
->cc
, "cc");
645 $cc_string = $cc['str'];
646 $url_cc_string = $cc['url_str'];
648 /** FORMAT THE BCC STRING **/
650 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
651 $bcc_string = $bcc['str'];
652 $url_bcc_string = $bcc['url_str'];
654 if ($default_use_priority) {
655 $priority_level = substr($message->header
->priority
,0,1);
657 switch($priority_level) {
658 /* check for a higher then normal priority. */
661 $priority_string = _("High");
664 /* check for a lower then normal priority. */
667 $priority_string = _("Low");
670 /* check for a normal priority. */
673 $priority_level = '3';
674 $priority_string = _("Normal");
680 /** make sure everything will display in HTML format **/
681 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
682 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
684 $idents = getPref($data_dir, $username, 'identities');
685 if (!empty($idents) && $idents > 1) {
686 for ($i = 1; $i < $idents; $i++
) {
687 $enc_from_name = '"'.
688 encodeHeader(getPref($data_dir,
691 '" <' . getPref($data_dir, $username,
692 'email_address' . $i) . '>';
693 if (htmlspecialchars($enc_from_name) == $from_name) {
700 do_hook('read_body_top');
702 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
703 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
704 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
706 '<TD ALIGN="LEFT" WIDTH="33%">' .
708 '<A HREF="' . $base_uri . 'src/';
710 if ($where && $what) {
714 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
716 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
718 echo _("Message List") .
719 '</A> | ' .
720 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
721 if ($where && $what) {
722 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
724 echo "sort=$sort&startMessage=$startMessage\">";
726 echo _("Delete") . '</A> ';
727 if (($mailbox == $draft_folder) && ($save_as_draft)) {
728 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
729 "identity=$identity&send_to=$url_to_string&".
730 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
731 "subject=$url_subj&mailprio=$priority_level&".
732 "draft_id=$passed_id&ent_num=$ent_num";
734 if ($compose_new_win == '1') {
735 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
737 echo '| <A HREF="' . $comp_uri .'"';
740 _("Resume Draft") . '</a>';
742 if ($mailbox == $sent_folder) {
743 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
744 "identity=$identity&send_to=$url_to_string&".
745 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
746 "subject=$url_subj&mailprio=$priority_level&".
747 "ent_num=$ent_num&passed_id=$passed_id&edit_as_new=1";
749 if ($compose_new_win == '1') {
750 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
752 echo '| <A HREF="' . $comp_uri .'"';
755 _("Edit Message as New") . '</a>';
758 echo ' ' .
761 '<TD WIDTH="33%" ALIGN="CENTER">' .
764 if ( !($where && $what) ) {
765 if ($currentArrayIndex == -1) {
766 echo 'Previous | Next';
768 $prev = findPreviousMessage();
769 $next = findNextMessage();
772 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
774 echo _("Previous") . ' | ';
778 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
786 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
789 $comp_uri = $base_uri . "src/compose.php?forward_id=$passed_id&".
790 "forward_subj=$url_subj&".
791 ($default_use_priority?
"mailprio=$priority_level&":'').
792 "mailbox=$urlMailbox&ent_num=$ent_num";
794 if ($compose_new_win == '1') {
795 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
797 echo '| <A HREF="' . $comp_uri .'"';
804 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replyto&".
805 "reply_subj=$url_subj&".
806 ($default_use_priority?
"mailprio=$priority_level&":'').
807 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
809 if ($compose_new_win == '1') {
810 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
812 echo '| <A HREF="' . $comp_uri .'"';
819 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replytoall&".
820 "send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
821 ($default_use_priority?
"mailprio=$priority_level&":'').
822 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
824 if ($compose_new_win == '1') {
825 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
827 echo '| <A HREF="' . $comp_uri .'"';
838 '<TR><TD WIDTH="100%">' .
839 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
843 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
845 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
846 "<B>$subject</B> \n" .
848 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
849 '" ALIGN=right VALIGN=top NOWRAP><small>'.
850 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
852 /* From a search... */
853 if ($where && $what) {
854 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
855 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
857 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
858 _("View Full Header") . "</A>\n";
861 /* Output the printer friendly link if we are in subtle mode. */
862 if ($pf_subtle_link) {
863 echo printer_friendly_link(true);
866 do_hook("read_body_header_right");
867 echo '</small></TD>' .
872 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
874 '</TD><TD BGCOLOR="' . $color[0] . '">' .
875 "<B>$from_name</B> \n" .
880 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
882 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
883 "<B>$dateString</B> \n" .
889 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
891 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
892 "<B>$to_string</B> \n" .
896 if (isset($cc_string) && $cc_string <> '') {
898 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
900 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
901 "<B>$cc_string</B> " .
907 if (isset($bcc_string) && $bcc_string <> '') {
909 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
911 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
912 "<B>$bcc_string</B> " .
916 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
918 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
919 _("Priority") . ': '.
920 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
921 "<B>$priority_string</B> " .
926 if ($show_xmailer_default) {
927 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
928 $response, $readmessage);
929 $mailer = substr($read[1], strpos($read[1], " "));
932 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
934 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
935 "<B>$mailer</B> " .
941 /* Output the printer friendly link if we are not in subtle mode. */
942 if (!$pf_subtle_link) {
943 echo printer_friendly_link(true);
946 if ($default_use_mdn) {
947 if ($mdn_user_support) {
949 // debug gives you the capability to remove mdn-flags
950 // $MDNDebug = false;
951 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
952 $response, $readmessage);
953 $MDN_to = substr($read[1], strpos($read[1], ' '));
954 $MDN_flag_present = false;
956 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
957 $response, $readmessage);
958 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
961 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
963 if ( $MDN_flag_present && $supportMDN) {
964 $sendreceipt = 'removeMDN';
965 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
970 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
971 _("Read receipt") . ': ' .
972 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
975 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
981 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
982 _("Read receipt") . ': ' .
983 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
984 '<B>'._("send").'</B>'.
991 } // when deleted or draft flag is set don't offer to send a MDN response
992 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
994 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
995 _("Read receipt") . ': '.
996 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
997 '<B>' . _("requested") . "</B>" .
1001 // if no MDNsupport don't use the annoying popup messages
1002 else if ( !$FirstTimeSee ) {
1003 $sendreceipt = 'send';
1004 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1006 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
1007 _("Read receipt") . ': ' .
1008 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
1009 '<B>' . _("requested") .
1010 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
1016 $sendreceipt = 'send';
1017 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1018 if ($javascript_on) {
1019 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
1021 " if (window.confirm(\"" .
1022 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
1024 ' window.open('.$url.',"right");' . "\n" .
1030 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
1031 _("Read receipt") . ': ' .
1032 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
1033 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
1034 _("Send read receipt now") . '] </a>' ." \n" .
1041 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
1042 } else if ( $sendreceipt == 'send' ) {
1043 if ( !$MDN_flag_present) {
1044 if (isset($identity) ) {
1045 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
1047 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
1050 $final_recipient = trim($final_recipient);
1051 if ($final_recipient == '' ) {
1052 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
1055 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
1056 ToggleMDNflag( true);
1060 $sendreceipt = 'removeMDN';
1061 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1064 if ($MDNDebug && $supportMDN) {
1066 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
1067 " "._("Read receipt").": \n".
1068 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
1069 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
1075 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
1076 " "._("Read receipt").": \n".
1077 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
1078 ' <B>'._("send").'</B>'. "\n" .
1085 elseif ($sendreceipt == 'removeMDN' ) {
1086 ToggleMDNflag ( false );
1088 $sendreceipt = 'send';
1089 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1091 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
1092 _("Read receipt") . ': ' .
1093 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
1094 '<B>' . _("requested") .
1095 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
1104 do_hook('read_body_header');
1110 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
1111 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
1115 echo '</TD></TR></TABLE>' .
1116 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
1117 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
1120 /* show attached images inline -- if pref'fed so */
1121 if (($attachment_common_show_images) &&
1122 is_array($attachment_common_show_images_list)) {
1124 foreach ($attachment_common_show_images_list as $img) {
1125 $imgurl = '../src/download.php' .
1127 'passed_id=' . urlencode($img['passed_id']) .
1128 '&mailbox=' . urlencode($mailbox) .
1129 '&passed_ent_id=' . urlencode($img['ent_id']) .
1130 '&absolute_dl=true';
1132 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
1135 "<img src=\"$imgurl\">\n" .
1144 do_hook('read_body_bottom');
1145 do_hook('html_bottom');
1146 sqimap_logout($imapConnection);