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, $thread_sort_messages;
32 if ($thread_sort_messages == 1) {
36 if ($currentArrayIndex != 1) {
37 $result = $currentArrayIndex - 1;
40 if (!is_array($msort)) {
43 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
44 if ($currentArrayIndex == $msgs[$key]['ID']) {
48 $result = $msgs[$key]['ID'];
56 /** Removes just one address from the list of addresses. */
57 function RemoveAddress(&$addr_list, $addr) {
59 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
60 unset($addr_list[$key_to_delete]);
65 /** returns the index of the previous message from the array. */
66 function findPreviousMessage() {
67 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
68 $mailbox, $data_dir, $username, $thread_sort_messages;
69 if ($thread_sort_messages == 1) {
76 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
77 if ($currentArrayIndex != $numMessages) {
78 $result = $currentArrayIndex +
1;
81 if (!is_array($msort)) {
84 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
85 if ($currentArrayIndex == $msgs[$key]['ID']) {
89 $result = $msgs[$key]['ID'];
99 * Displays a link to a page where the message is displayed more
100 * "printer friendly".
102 function printer_friendly_link() {
103 global $passed_id, $mailbox, $ent_num, $color,
107 if (strlen(trim($mailbox)) < 1) {
111 $params = '?passed_ent_id=' . $ent_num .
112 '&mailbox=' . urlencode($mailbox) .
113 '&passed_id=' . $passed_id;
115 $print_text = _("View Printable Version");
117 if (!$pf_subtle_link) {
118 /* The link is large, on the bottom of the header panel. */
119 $result = '<tr bgcolor="' . $color[0] . '">' .
120 '<td class="medText" align="right" valign="top">' .
122 '</td><td class="medText" valign="top" colspan="2">'."\n";
124 /* The link is subtle, below "view full header". */
128 /* Output the link. */
129 if ($javascript_on) {
130 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
132 " function printFormat() {\n" .
133 ' window.open("../src/printer_friendly_main.php' .
134 $params . '","Print","width=800,height=600");' . "\n".
138 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
140 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
141 "$params\">$print_text</A>\n";
144 if (!$pf_subtle_link) {
145 /* The link is large, on the bottom of the header panel. */
146 $result .= '</td></tr>' . "\n";
152 function ServerMDNSupport( $read ) {
153 /* escaping $ doesn't work -> \x36 */
154 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
158 function SendMDN ( $recipient , $sender) {
159 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
160 $version, $attachments, $identity, $data_dir, $passed_id;
162 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
163 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
167 $senton = getLongDateString( $header->date
);
168 $to_array = $header->to
;
170 foreach ($to_array as $line) {
174 $subject = $header->subject
;
175 $now = getLongDateString( time() );
177 $body = _("Your message") . "\r\n\r\n" .
178 "\t" . _("To:") . ' ' . $to . "\r\n" .
179 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
180 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
182 sprintf( _("Was displayed on %s"), $now );
186 $original_recipient = $to;
187 $original_message_id = $header->message_id
;
189 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
190 if ($original_recipient != '') {
191 $part2 .= "Original-Recipient : $original_recipient\r\n";
193 $final_recipient = $sender;
194 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
195 "Original-Message-ID : $original_message_id\r\n" .
196 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
199 $localfilename = GenerateRandomString(32, 'FILE', 7);
200 $full_localfilename = "$hashed_attachment_dir/$localfilename";
202 $fp = fopen( $full_localfilename, 'w');
203 fwrite ($fp, $part2);
206 $newAttachment = array();
207 $newAttachment['localfilename'] = $localfilename;
208 $newAttachment['type'] = "message/disposition-notification";
209 $newAttachment['session']=-1;
210 $attachments[] = $newAttachment;
211 $MDN_to = trim($recipient);
214 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3, -1) );
218 function ToggleMDNflag ( $set ) {
219 global $imapConnection, $passed_id, $mailbox;
220 sqimap_mailbox_select($imapConnection, $mailbox);
223 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
224 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
228 function ClearAttachments() {
229 global $username, $attachments, $attachment_dir;
231 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
233 $rem_attachments = array();
234 foreach ($attachments as $info) {
235 if ($info->session
== -1) {
236 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
237 if (file_exists($attached_file)) {
238 unlink($attached_file);
241 $rem_attachments[] = $info;
244 $attachments = rem_attachments
;
247 function formatRecipientString($recipients, $item ) {
248 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
253 if (isset ($recipients[0]) && trim($recipients[0])) {
259 $show = "&show_more=1&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
260 $show_n = "&show_more=0&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
263 $show = "&show_more=$show_more&show_more_cc=1&show_more_bcc=$show_more_bcc";
264 $show_n = "&show_more=$show_more&show_more_cc=0&show_more_bcc=$show_more_bcc";
265 $show_more = $show_more_cc;
268 $show = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=1";
269 $show_n = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=0";
270 $show_more = $show_more_bcc;
276 while ($i < count($ary)) {
277 $ary[$i] = htmlspecialchars(decodeHeader($ary[$i]));
278 $url_string .= $ary[$i];
280 $string = "$string<BR>$ary[$i]";
282 $string = "$ary[$i]";
286 if (count($ary) > 1) {
287 if ($show_more == false) {
289 /* From a search... */
290 $string .= ' (<A HREF="' . $base_uri .
291 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
292 if (isset($where) && isset($what)) {
293 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show\">$echo_more</A>)";
295 $string .= "sort=$sort&startMessage=$startMessage"."$show\">$echo_more</A>)";
299 } else if ($i == 1) {
300 /* From a search... */
301 $string .= ' (<A HREF="' . $base_uri .
302 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
303 if (isset($where) && isset($what)) {
304 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show_n\">$echo_less</A>)";
306 $string .= "sort=$sort&startMessage=$startMessage"."$show_n\">$echo_less</A>)";
316 $url_string = urlencode($url_string);
318 $result['str'] = $string;
319 $result['url_str'] = $url_string;
326 * Main of read_boby.php --------------------------------------------------
335 if ( isset( $mailbox ) ) {
336 $mailbox = urldecode( $mailbox );
338 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
339 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
344 * The following code sets necesarry stuff for the MDN thing
346 if( $default_use_mdn &&
347 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
349 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
350 $flags = sqimap_get_flags ($imapConnection, $passed_id);
351 $FirstTimeSee = !(in_array( 'Seen', $flags ));
354 displayPageHeader($color, $mailbox);
358 * The following code shows the header of the message and then exit
360 if (isset($view_hdr)) {
361 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
364 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
365 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>" . _("Viewing Full Header") . '</B> - '.
366 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
367 if (isset($where) && isset($what)) {
368 // Got here from a search
369 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
371 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
373 echo _("View message") . "</a></b></td></tr></table>\n" .
374 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
378 for ($i=1; $i < count($read); $i++
) {
379 $line = htmlspecialchars($read[$i]);
380 if (eregi("^>", $line)) {
382 $first[$i] = ' ';
384 } else if (eregi("^[ |\t]", $line)) {
387 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
388 $first[$i] = $regs[1] . ':';
389 $second[$i] = $regs[2];
392 $second[$i] = trim($line);
396 for ($i=0; $i < count($second); $i = $j) {
397 if (isset($first[$i])) {
400 if (isset($second[$i])) {
401 $s = nl2br($second[$i]);
404 while (($first[$j] == '') && ($j < count($first))) {
405 $s .= ' ' . nl2br($second[$j]);
410 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
413 echo "</td></tr></table>\n" .
415 sqimap_logout($imapConnection);
420 $currentArrayIndex = $passed_id;
422 $currentArrayIndex = -1;
425 for ($i = 0; $i < count($msgs); $i++
) {
426 if ($msgs[$i]['ID'] == $passed_id) {
427 $msgs[$i]['FLAG_SEEN'] = true;
431 // $message contains all information about the message
432 // including header and body
433 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
435 /** translate the subject and mailbox into url-able text **/
436 $url_subj = urlencode(trim($message->header
->subject
));
437 $urlMailbox = urlencode($mailbox);
439 if (isset($message->header
->replyto
)) {
440 $url_replyto = urlencode($message->header
->replyto
);
443 $url_replytoall = $url_replyto;
445 // If we are replying to all, then find all other addresses and
446 // add them to the list. Remove duplicates.
447 // This is somewhat messy, so I'll explain:
448 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
449 $url_replytoall_extra_addrs = array_merge(
450 array($message->header
->from
),
451 $message->header
->to
,
455 // 2) Make one big string out of them
456 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
458 // 3) Parse that into an array of addresses
459 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
461 // 4) Make them unique -- weed out duplicates
462 // (Coded for PHP 4.0.0)
463 $url_replytoall_extra_addrs =
464 array_keys(array_flip($url_replytoall_extra_addrs));
466 // 5) Remove the addresses we'll be sending the message 'to'
467 $url_replytoall_avoid_addrs = '';
468 if (isset($message->header
->replyto
)) {
469 $url_replytoall_avoid_addrs = $message->header
->replyto
;
472 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
473 foreach ($url_replytoall_avoid_addrs as $addr) {
474 RemoveAddress($url_replytoall_extra_addrs, $addr);
477 // 6) Remove our identities from the CC list (they still can be in the
478 // TO list) only if $include_self_reply_all is turned off
479 if (!$include_self_reply_all) {
480 RemoveAddress($url_replytoall_extra_addrs,
481 getPref($data_dir, $username, 'email_address'));
482 $idents = getPref($data_dir, $username, 'identities');
483 if ($idents != '' && $idents > 1) {
484 for ($i = 1; $i < $idents; $i ++
) {
485 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
486 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
491 // 7) Smoosh back into one nice line
492 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
495 $url_replytoallcc = urlencode($url_replytoallcc);
497 $dateString = getLongDateString($message->header
->date
);
499 // What do we reply to -- text only, if possible
500 $ent_num = findDisplayEntity($message);
502 /** TEXT STRINGS DEFINITIONS **/
503 $echo_more = _("more");
504 $echo_less = _("less");
506 if (!isset($show_more_cc)) {
507 $show_more_cc = FALSE;
510 if (!isset($show_more_bcc)) {
511 $show_more_bcc = FALSE;
514 /** FORMAT THE TO STRING **/
515 $to = formatRecipientString($message->header
->to
, "to");
516 $to_string = $to['str'];
517 $url_to_string = $to['url_str'];
520 /** FORMAT THE CC STRING **/
522 $cc = formatRecipientString($message->header
->cc
, "cc");
523 $cc_string = $cc['str'];
524 $url_cc_string = $cc['url_str'];
526 /** FORMAT THE BCC STRING **/
528 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
529 $bcc_string = $bcc['str'];
530 $url_bcc_string = $bcc['url_str'];
532 if ($default_use_priority) {
533 $priority_level = substr($message->header
->priority
,0,1);
535 switch($priority_level) {
536 /* check for a higher then normal priority. */
539 $priority_string = _("High");
542 /* check for a lower then normal priority. */
545 $priority_string = _("Low");
548 /* check for a normal priority. */
551 $priority_level = '3';
552 $priority_string = _("Normal");
558 /** make sure everything will display in HTML format **/
559 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
560 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
562 do_hook('read_body_top');
564 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
565 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
566 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
568 '<TD ALIGN="LEFT" WIDTH="33%">' .
570 '<A HREF="' . $base_uri . 'src/';
572 if ($where && $what) {
576 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
578 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
580 echo _("Message List") .
581 '</A> | ' .
582 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
583 if ($where && $what) {
584 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
586 echo "sort=$sort&startMessage=$startMessage\">";
588 echo _("Delete") . '</A> ';
589 if (($mailbox == $draft_folder) && ($save_as_draft)) {
590 echo '| <A HREF="' . $base_uri .
591 "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" . '"';
592 if ($compose_new_win == '1') {
593 echo 'TARGET="compose_window" onClick="comp_in_new()"';
596 _("Resume Draft") . '</a>';
599 echo ' ' .
602 '<TD WIDTH="33%" ALIGN="CENTER">' .
605 if ( !($where && $what) ) {
607 if ($currentArrayIndex == -1) {
608 echo 'Previous | Next';
610 $prev = findPreviousMessage();
611 $next = findNextMessage();
614 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
616 echo _("Previous") . ' | ';
620 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
628 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
630 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
631 ($default_use_priority?
"mailprio=$priority_level&":'')
632 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
633 if ($compose_new_win == '1') {
634 echo 'TARGET="compose_window" onClick="comp_in_new()"';
638 '</A> | ' .
639 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
640 ($default_use_priority?
"mailprio=$priority_level&":'').
641 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
642 if ($compose_new_win == '1') {
643 echo 'TARGET="compose_window" onClick="comp_in_new()"';
647 '</A> | ' .
648 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
649 ($default_use_priority?
"mailprio=$priority_level&":'').
650 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
651 if ($compose_new_win == '1') {
652 echo 'TARGET="compose_window" onClick="comp_in_new()"';
662 '<TR><TD WIDTH="100%">' .
663 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
667 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
669 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
670 "<B>$subject</B> \n" .
672 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
673 '" ALIGN=right VALIGN=top NOWRAP><small>'.
674 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
676 /* From a search... */
677 if ($where && $what) {
678 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
679 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
681 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
682 _("View Full Header") . "</A>\n";
685 /* Output the printer friendly link if we are in subtle mode. */
686 if ($pf_subtle_link) {
687 echo printer_friendly_link(true);
690 do_hook("read_body_header_right");
691 echo '</small></TD>' .
696 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
698 '</TD><TD BGCOLOR="' . $color[0] . '">' .
699 "<B>$from_name</B> \n" .
704 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
706 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
707 "<B>$dateString</B> \n" .
713 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
715 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
716 "<B>$to_string</B> \n" .
720 if (isset($cc_string) && $cc_string <> '') {
722 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
724 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
725 "<B>$cc_string</B> " .
731 if (isset($bcc_string) && $bcc_string <> '') {
733 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
735 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
736 "<B>$bcc_string</B> " .
740 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
742 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
743 _("Priority") . ': '.
744 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
745 "<B>$priority_string</B> " .
750 if ($show_xmailer_default) {
751 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
752 $response, $readmessage);
753 $mailer = substr($read[1], strpos($read[1], " "));
756 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
758 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
759 "<B>$mailer</B> " .
765 /* Output the printer friendly link if we are not in subtle mode. */
766 if (!$pf_subtle_link) {
767 echo printer_friendly_link(true);
770 if ($default_use_mdn) {
771 if ($mdn_user_support) {
773 // debug gives you the capability to remove mdn-flags
774 // $MDNDebug = false;
775 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
776 $response, $readmessage);
777 $MDN_to = substr($read[1], strpos($read[1], ' '));
778 $MDN_flag_present = false;
780 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
781 $response, $readmessage);
783 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
786 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
788 if ( $MDN_flag_present && $supportMDN) {
789 $sendreceipt = 'removeMDN';
790 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
795 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
796 _("Read receipt") . ': ' .
797 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
800 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
806 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
807 _("Read receipt") . ': ' .
808 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
809 '<B>'._("send").'</B>'.
816 } // when deleted or draft flag is set don't offer to send a MDN response
817 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
819 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
820 _("Read receipt") . ': '.
821 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
822 '<B>' . _("requested") . "</B>" .
826 // if no MDNsupport don't use the annoying popup messages
827 else if ( !$FirstTimeSee ) {
828 $sendreceipt = 'send';
829 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
831 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
832 _("Read receipt") . ': ' .
833 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
834 '<B>' . _("requested") .
835 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
841 $sendreceipt = 'send';
842 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
843 if ($javascript_on) {
844 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
846 " if (window.confirm(\"" .
847 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
849 " window.location=($url); \n" .
850 ' window.reload()' . "\n" .
856 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
857 _("Read receipt") . ': ' .
858 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
859 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
860 _("Send read receipt now") . '] </a>' ." \n" .
867 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
868 } else if ( $sendreceipt == 'send' ) {
869 if ( !$MDN_flag_present) {
870 if (isset($identity) ) {
871 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
873 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
876 $final_recipient = trim($final_recipient);
877 if ($final_recipient == '' ) {
878 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
881 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
882 ToggleMDNflag( true);
885 $sendreceipt = 'removeMDN';
886 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
889 if ($MDNDebug && $supportMDN) {
891 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
892 " "._("Read receipt").": \n".
893 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
894 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
900 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
901 " "._("Read receipt").": \n".
902 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
903 ' <B>'._("send").'</B>'. "\n" .
910 elseif ($sendreceipt == 'removeMDN' ) {
911 ToggleMDNflag ( false );
913 $sendreceipt = 'send';
914 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
916 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
917 _("Read receipt") . ': ' .
918 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
919 '<B>' . _("requested") .
920 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
929 do_hook('read_body_header');
936 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
937 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
939 formatBody($imapConnection, $message, $color, $wrap_at).
940 '</TD></TR></TABLE>' .
941 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
942 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
945 /* show attached images inline -- if pref'fed so */
946 if (($attachment_common_show_images) &&
947 is_array($attachment_common_show_images_list)) {
949 foreach ($attachment_common_show_images_list as $img) {
950 $imgurl = '../src/download.php' .
952 'passed_id=' . urlencode($img['passed_id']) .
953 '&mailbox=' . urlencode($mailbox) .
954 '&passed_ent_id=' . urlencode($img['ent_id']) .
955 '&absolute_dl=true';
957 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
960 "<img src=\"$imgurl\">\n" .
969 do_hook('read_body_bottom');
970 do_hook('html_bottom');
971 sqimap_logout($imapConnection);