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 * returns 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 ($thread_sort_messages == 1) {
36 if ($sort == 6 && $allow_server_sort != TRUE) {
37 if ($currentArrayIndex != 1) {
38 $result = $currentArrayIndex - 1;
41 if (!is_array($msort)) {
44 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
45 if ($currentArrayIndex == $msgs[$key]['ID']) {
49 $result = $msgs[$key]['ID'];
57 /** Removes just one address from the list of addresses. */
58 function RemoveAddress(&$addr_list, $addr) {
60 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
61 unset($addr_list[$key_to_delete]);
66 /** returns the index of the previous message from the array. */
67 function findPreviousMessage() {
68 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
69 $mailbox, $data_dir, $username, $thread_sort_messages,
71 if ($thread_sort_messages == 1) {
77 if ($sort == 6 && $allow_server_sort != TRUE) {
78 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
79 if ($currentArrayIndex != $numMessages) {
80 $result = $currentArrayIndex +
1;
83 if (!is_array($msort)) {
86 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
87 if ($currentArrayIndex == $msgs[$key]['ID']) {
91 $result = $msgs[$key]['ID'];
101 * Displays a link to a page where the message is displayed more
102 * "printer friendly".
104 function printer_friendly_link() {
105 global $passed_id, $mailbox, $ent_num, $color,
109 if (strlen(trim($mailbox)) < 1) {
113 $params = '?passed_ent_id=' . $ent_num .
114 '&mailbox=' . urlencode($mailbox) .
115 '&passed_id=' . $passed_id;
117 $print_text = _("View Printable Version");
119 if (!$pf_subtle_link) {
120 /* The link is large, on the bottom of the header panel. */
121 $result = '<tr bgcolor="' . $color[0] . '">' .
122 '<td class="medText" align="right" valign="top">' .
124 '</td><td class="medText" valign="top" colspan="2">'."\n";
126 /* The link is subtle, below "view full header". */
130 /* Output the link. */
131 if ($javascript_on) {
132 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
134 " function printFormat() {\n" .
135 ' window.open("../src/printer_friendly_main.php' .
136 $params . '","Print","width=800,height=600");' . "\n".
140 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
142 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
143 "$params\">$print_text</A>\n";
146 if (!$pf_subtle_link) {
147 /* The link is large, on the bottom of the header panel. */
148 $result .= '</td></tr>' . "\n";
154 function ServerMDNSupport( $read ) {
155 /* escaping $ doesn't work -> \x36 */
156 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
160 function SendMDN ( $recipient , $sender) {
161 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
162 $version, $attachments, $identity, $data_dir, $passed_id;
164 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
165 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
169 $senton = getLongDateString( $header->date
);
170 $to_array = $header->to
;
172 foreach ($to_array as $line) {
176 $subject = $header->subject
;
177 $now = getLongDateString( time() );
179 $body = _("Your message") . "\r\n\r\n" .
180 "\t" . _("To:") . ' ' . $to . "\r\n" .
181 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
182 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
184 sprintf( _("Was displayed on %s"), $now );
188 $original_recipient = $to;
189 $original_message_id = $header->message_id
;
191 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
192 if ($original_recipient != '') {
193 $part2 .= "Original-Recipient : $original_recipient\r\n";
195 $final_recipient = $sender;
196 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
197 "Original-Message-ID : $original_message_id\r\n" .
198 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
201 $localfilename = GenerateRandomString(32, 'FILE', 7);
202 $full_localfilename = "$hashed_attachment_dir/$localfilename";
204 $fp = fopen( $full_localfilename, 'w');
205 fwrite ($fp, $part2);
208 $newAttachment = array();
209 $newAttachment['localfilename'] = $localfilename;
210 $newAttachment['type'] = "message/disposition-notification";
211 $newAttachment['session']=-1;
212 $attachments[] = $newAttachment;
213 $MDN_to = trim($recipient);
216 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3, -1) );
220 function ToggleMDNflag ( $set ) {
221 global $imapConnection, $passed_id, $mailbox;
222 sqimap_mailbox_select($imapConnection, $mailbox);
225 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
226 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
230 function ClearAttachments() {
231 global $username, $attachments, $attachment_dir;
233 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
235 $rem_attachments = array();
236 foreach ($attachments as $info) {
237 if ($info->session
== -1) {
238 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
239 if (file_exists($attached_file)) {
240 unlink($attached_file);
243 $rem_attachments[] = $info;
246 $attachments = rem_attachments
;
249 function formatRecipientString($recipients, $item ) {
250 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
255 if (isset ($recipients[0]) && trim($recipients[0])) {
261 $show = "&show_more=1&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
262 $show_n = "&show_more=0&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
265 $show = "&show_more=$show_more&show_more_cc=1&show_more_bcc=$show_more_bcc";
266 $show_n = "&show_more=$show_more&show_more_cc=0&show_more_bcc=$show_more_bcc";
267 $show_more = $show_more_cc;
270 $show = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=1";
271 $show_n = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=0";
272 $show_more = $show_more_bcc;
278 while ($i < count($ary)) {
279 $ary[$i] = htmlspecialchars(decodeHeader($ary[$i]));
280 $url_string .= $ary[$i];
282 $string = "$string<BR>$ary[$i]";
284 $string = "$ary[$i]";
288 if (count($ary) > 1) {
289 if ($show_more == false) {
291 /* From a search... */
292 $string .= ' (<A HREF="' . $base_uri .
293 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
294 if (isset($where) && isset($what)) {
295 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show\">$echo_more</A>)";
297 $string .= "sort=$sort&startMessage=$startMessage"."$show\">$echo_more</A>)";
301 } else if ($i == 1) {
302 /* From a search... */
303 $string .= ' (<A HREF="' . $base_uri .
304 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
305 if (isset($where) && isset($what)) {
306 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show_n\">$echo_less</A>)";
308 $string .= "sort=$sort&startMessage=$startMessage"."$show_n\">$echo_less</A>)";
318 $url_string = urlencode($url_string);
320 $result['str'] = $string;
321 $result['url_str'] = $url_string;
328 * Main of read_boby.php --------------------------------------------------
337 if ( isset( $mailbox ) ) {
338 $mailbox = urldecode( $mailbox );
340 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
341 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
346 * The following code sets necesarry stuff for the MDN thing
348 if( $default_use_mdn &&
349 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
351 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
352 $flags = sqimap_get_flags ($imapConnection, $passed_id);
353 $FirstTimeSee = !(in_array( 'Seen', $flags ));
356 displayPageHeader($color, $mailbox);
360 * The following code shows the header of the message and then exit
362 if (isset($view_hdr)) {
363 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
366 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
367 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>" . _("Viewing Full Header") . '</B> - '.
368 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
369 if (isset($where) && isset($what)) {
370 // Got here from a search
371 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
373 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
375 echo _("View message") . "</a></b></td></tr></table>\n" .
376 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
380 for ($i=1; $i < count($read); $i++
) {
381 $line = htmlspecialchars($read[$i]);
382 if (eregi("^>", $line)) {
384 $first[$i] = ' ';
386 } else if (eregi("^[ |\t]", $line)) {
389 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
390 $first[$i] = $regs[1] . ':';
391 $second[$i] = $regs[2];
394 $second[$i] = trim($line);
398 for ($i=0; $i < count($second); $i = $j) {
399 if (isset($first[$i])) {
402 if (isset($second[$i])) {
403 $s = nl2br($second[$i]);
406 while (($first[$j] == '') && ($j < count($first))) {
407 $s .= ' ' . nl2br($second[$j]);
412 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
415 echo "</td></tr></table>\n" .
417 sqimap_logout($imapConnection);
422 $currentArrayIndex = $passed_id;
424 $currentArrayIndex = -1;
427 for ($i = 0; $i < count($msgs); $i++
) {
428 if ($msgs[$i]['ID'] == $passed_id) {
429 $msgs[$i]['FLAG_SEEN'] = true;
433 // $message contains all information about the message
434 // including header and body
435 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
437 /** translate the subject and mailbox into url-able text **/
438 $url_subj = urlencode(trim($message->header
->subject
));
439 $urlMailbox = urlencode($mailbox);
441 if (isset($message->header
->replyto
)) {
442 $url_replyto = urlencode($message->header
->replyto
);
445 $url_replytoall = $url_replyto;
447 // If we are replying to all, then find all other addresses and
448 // add them to the list. Remove duplicates.
449 // This is somewhat messy, so I'll explain:
450 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
451 $url_replytoall_extra_addrs = array_merge(
452 array($message->header
->from
),
453 $message->header
->to
,
457 // 2) Make one big string out of them
458 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
460 // 3) Parse that into an array of addresses
461 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
463 // 4) Make them unique -- weed out duplicates
464 // (Coded for PHP 4.0.0)
465 $url_replytoall_extra_addrs =
466 array_keys(array_flip($url_replytoall_extra_addrs));
468 // 5) Remove the addresses we'll be sending the message 'to'
469 $url_replytoall_avoid_addrs = '';
470 if (isset($message->header
->replyto
)) {
471 $url_replytoall_avoid_addrs = $message->header
->replyto
;
474 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
475 foreach ($url_replytoall_avoid_addrs as $addr) {
476 RemoveAddress($url_replytoall_extra_addrs, $addr);
479 // 6) Remove our identities from the CC list (they still can be in the
480 // TO list) only if $include_self_reply_all is turned off
481 if (!$include_self_reply_all) {
482 RemoveAddress($url_replytoall_extra_addrs,
483 getPref($data_dir, $username, 'email_address'));
484 $idents = getPref($data_dir, $username, 'identities');
485 if ($idents != '' && $idents > 1) {
486 for ($i = 1; $i < $idents; $i ++
) {
487 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
488 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
493 // 7) Smoosh back into one nice line
494 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
497 $url_replytoallcc = urlencode($url_replytoallcc);
499 $dateString = getLongDateString($message->header
->date
);
501 // What do we reply to -- text only, if possible
502 $ent_num = findDisplayEntity($message);
504 /** TEXT STRINGS DEFINITIONS **/
505 $echo_more = _("more");
506 $echo_less = _("less");
508 if (!isset($show_more_cc)) {
509 $show_more_cc = FALSE;
512 if (!isset($show_more_bcc)) {
513 $show_more_bcc = FALSE;
516 /** FORMAT THE TO STRING **/
517 $to = formatRecipientString($message->header
->to
, "to");
518 $to_string = $to['str'];
519 $url_to_string = $to['url_str'];
522 /** FORMAT THE CC STRING **/
524 $cc = formatRecipientString($message->header
->cc
, "cc");
525 $cc_string = $cc['str'];
526 $url_cc_string = $cc['url_str'];
528 /** FORMAT THE BCC STRING **/
530 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
531 $bcc_string = $bcc['str'];
532 $url_bcc_string = $bcc['url_str'];
534 if ($default_use_priority) {
535 $priority_level = substr($message->header
->priority
,0,1);
537 switch($priority_level) {
538 /* check for a higher then normal priority. */
541 $priority_string = _("High");
544 /* check for a lower then normal priority. */
547 $priority_string = _("Low");
550 /* check for a normal priority. */
553 $priority_level = '3';
554 $priority_string = _("Normal");
560 /** make sure everything will display in HTML format **/
561 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
562 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
564 do_hook('read_body_top');
566 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
567 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
568 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
570 '<TD ALIGN="LEFT" WIDTH="33%">' .
572 '<A HREF="' . $base_uri . 'src/';
574 if ($where && $what) {
578 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
580 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
582 echo _("Message List") .
583 '</A> | ' .
584 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
585 if ($where && $what) {
586 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
588 echo "sort=$sort&startMessage=$startMessage\">";
590 echo _("Delete") . '</A> ';
591 if (($mailbox == $draft_folder) && ($save_as_draft)) {
592 echo '| <A HREF="' . $base_uri .
593 "src/compose.php?mailbox=$mailbox&send_to=$url_to_string&send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num" . '"';
594 if ($compose_new_win == '1') {
595 echo 'TARGET="compose_window" onClick="comp_in_new()"';
598 _("Resume Draft") . '</a>';
601 echo ' ' .
604 '<TD WIDTH="33%" ALIGN="CENTER">' .
607 if ( !($where && $what) ) {
609 if ($currentArrayIndex == -1) {
610 echo 'Previous | Next';
612 $prev = findPreviousMessage();
613 $next = findNextMessage();
616 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
618 echo _("Previous") . ' | ';
622 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
630 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
632 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
633 ($default_use_priority?
"mailprio=$priority_level&":'')
634 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
635 if ($compose_new_win == '1') {
636 echo 'TARGET="compose_window" onClick="comp_in_new()"';
640 '</A> | ' .
641 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
642 ($default_use_priority?
"mailprio=$priority_level&":'').
643 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
644 if ($compose_new_win == '1') {
645 echo 'TARGET="compose_window" onClick="comp_in_new()"';
649 '</A> | ' .
650 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
651 ($default_use_priority?
"mailprio=$priority_level&":'').
652 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
653 if ($compose_new_win == '1') {
654 echo 'TARGET="compose_window" onClick="comp_in_new()"';
664 '<TR><TD WIDTH="100%">' .
665 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
669 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
671 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
672 "<B>$subject</B> \n" .
674 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
675 '" ALIGN=right VALIGN=top NOWRAP><small>'.
676 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
678 /* From a search... */
679 if ($where && $what) {
680 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
681 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
683 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
684 _("View Full Header") . "</A>\n";
687 /* Output the printer friendly link if we are in subtle mode. */
688 if ($pf_subtle_link) {
689 echo printer_friendly_link(true);
692 do_hook("read_body_header_right");
693 echo '</small></TD>' .
698 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
700 '</TD><TD BGCOLOR="' . $color[0] . '">' .
701 "<B>$from_name</B> \n" .
706 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
708 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
709 "<B>$dateString</B> \n" .
715 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
717 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
718 "<B>$to_string</B> \n" .
722 if (isset($cc_string) && $cc_string <> '') {
724 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
726 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
727 "<B>$cc_string</B> " .
733 if (isset($bcc_string) && $bcc_string <> '') {
735 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
737 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
738 "<B>$bcc_string</B> " .
742 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
744 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
745 _("Priority") . ': '.
746 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
747 "<B>$priority_string</B> " .
752 if ($show_xmailer_default) {
753 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
754 $response, $readmessage);
755 $mailer = substr($read[1], strpos($read[1], " "));
758 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
760 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
761 "<B>$mailer</B> " .
767 /* Output the printer friendly link if we are not in subtle mode. */
768 if (!$pf_subtle_link) {
769 echo printer_friendly_link(true);
772 if ($default_use_mdn) {
773 if ($mdn_user_support) {
775 // debug gives you the capability to remove mdn-flags
776 // $MDNDebug = false;
777 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
778 $response, $readmessage);
779 $MDN_to = substr($read[1], strpos($read[1], ' '));
780 $MDN_flag_present = false;
782 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
783 $response, $readmessage);
785 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
788 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
790 if ( $MDN_flag_present && $supportMDN) {
791 $sendreceipt = 'removeMDN';
792 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
797 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
798 _("Read receipt") . ': ' .
799 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
802 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
808 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
809 _("Read receipt") . ': ' .
810 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
811 '<B>'._("send").'</B>'.
818 } // when deleted or draft flag is set don't offer to send a MDN response
819 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
821 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
822 _("Read receipt") . ': '.
823 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
824 '<B>' . _("requested") . "</B>" .
828 // if no MDNsupport don't use the annoying popup messages
829 else if ( !$FirstTimeSee ) {
830 $sendreceipt = 'send';
831 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
833 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
834 _("Read receipt") . ': ' .
835 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
836 '<B>' . _("requested") .
837 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
843 $sendreceipt = 'send';
844 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
845 if ($javascript_on) {
846 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
848 " if (window.confirm(\"" .
849 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
851 " window.location=($url); \n" .
852 ' window.reload()' . "\n" .
858 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
859 _("Read receipt") . ': ' .
860 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
861 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
862 _("Send read receipt now") . '] </a>' ." \n" .
869 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
870 } else if ( $sendreceipt == 'send' ) {
871 if ( !$MDN_flag_present) {
872 if (isset($identity) ) {
873 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
875 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
878 $final_recipient = trim($final_recipient);
879 if ($final_recipient == '' ) {
880 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
883 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
884 ToggleMDNflag( true);
887 $sendreceipt = 'removeMDN';
888 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
891 if ($MDNDebug && $supportMDN) {
893 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
894 " "._("Read receipt").": \n".
895 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
896 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
902 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
903 " "._("Read receipt").": \n".
904 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
905 ' <B>'._("send").'</B>'. "\n" .
912 elseif ($sendreceipt == 'removeMDN' ) {
913 ToggleMDNflag ( false );
915 $sendreceipt = 'send';
916 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
918 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
919 _("Read receipt") . ': ' .
920 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
921 '<B>' . _("requested") .
922 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
931 do_hook('read_body_header');
938 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
939 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
941 formatBody($imapConnection, $message, $color, $wrap_at).
942 '</TD></TR></TABLE>' .
943 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
944 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
947 /* show attached images inline -- if pref'fed so */
948 if (($attachment_common_show_images) &&
949 is_array($attachment_common_show_images_list)) {
951 foreach ($attachment_common_show_images_list as $img) {
952 $imgurl = '../src/download.php' .
954 'passed_id=' . urlencode($img['passed_id']) .
955 '&mailbox=' . urlencode($mailbox) .
956 '&passed_ent_id=' . urlencode($img['ent_id']) .
957 '&absolute_dl=true';
959 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
962 "<img src=\"$imgurl\">\n" .
971 do_hook('read_body_bottom');
972 do_hook('html_bottom');
973 sqimap_logout($imapConnection);