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;
34 if ($currentArrayIndex != 1) {
35 $result = $currentArrayIndex - 1;
38 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
39 if ($currentArrayIndex == $msgs[$key]['ID']) {
43 $result = $msgs[$key]['ID'];
51 /** Removes just one address from the list of addresses. */
52 function RemoveAddress(&$addr_list, $addr) {
54 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
55 unset($addr_list[$key_to_delete]);
60 /** returns the index of the previous message from the array. */
61 function findPreviousMessage() {
62 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
63 $mailbox, $data_dir, $username;
68 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
69 if ($currentArrayIndex != $numMessages) {
70 $result = $currentArrayIndex +
1;
73 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
74 if ($currentArrayIndex == $msgs[$key]['ID']) {
78 $result = $msgs[$key]['ID'];
88 * Displays a link to a page where the message is displayed more
91 function printer_friendly_link() {
92 global $passed_id, $mailbox, $ent_num, $color,
96 if (strlen(trim($mailbox)) < 1) {
100 $params = '?passed_ent_id=' . $ent_num .
101 '&mailbox=' . urlencode($mailbox) .
102 '&passed_id=' . $passed_id;
104 $print_text = _("View Printable Version");
106 if (!$pf_subtle_link) {
107 /* The link is large, on the bottom of the header panel. */
108 $result = '<tr bgcolor="' . $color[0] . '">' .
109 '<td class="medText" align="right" valign="top">' .
111 '</td><td class="medText" valign="top" colspan="2">'."\n";
113 /* The link is subtle, below "view full header". */
117 /* Output the link. */
118 if ($javascript_on) {
119 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
121 " function printFormat() {\n" .
122 ' window.open("../src/printer_friendly_main.php' .
123 $params . '","Print","width=800,height=600");' . "\n".
127 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
129 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
130 "$params\">$print_text</A>\n";
133 if (!$pf_subtle_link) {
134 /* The link is large, on the bottom of the header panel. */
135 $result .= '</td></tr>' . "\n";
141 function ServerMDNSupport( $read ) {
142 /* escaping $ doesn't work -> \x36 */
143 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
147 function SendMDN ( $recipient , $sender) {
148 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
149 $version, $attachments, $identity, $data_dir, $passed_id;
151 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
152 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
156 $senton = getLongDateString( $header->date
);
157 $to_array = $header->to
;
159 foreach ($to_array as $line) {
163 $subject = $header->subject
;
164 $now = getLongDateString( time() );
166 $body = _("Your message") . "\r\n\r\n" .
167 "\t" . _("To:") . ' ' . $to . "\r\n" .
168 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
169 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
171 sprintf( _("Was displayed on %s"), $now );
175 $original_recipient = $to;
176 $original_message_id = $header->message_id
;
178 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
179 if ($original_recipient != '') {
180 $part2 .= "Original-Recipient : $original_recipient\r\n";
182 $final_recipient = $sender;
183 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
184 "Original-Message-ID : $original_message_id\r\n" .
185 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
188 $localfilename = GenerateRandomString(32, 'FILE', 7);
189 $full_localfilename = "$hashed_attachment_dir/$localfilename";
191 $fp = fopen( $full_localfilename, 'w');
192 fwrite ($fp, $part2);
195 $newAttachment = array();
196 $newAttachment['localfilename'] = $localfilename;
197 $newAttachment['type'] = "message/disposition-notification";
199 $attachments[] = $newAttachment;
200 $MDN_to = trim($recipient);
203 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3) );
207 function ToggleMDNflag ( $set ) {
208 global $imapConnection, $passed_id, $mailbox;
209 sqimap_mailbox_select($imapConnection, $mailbox);
212 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
213 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
217 function ClearAttachments() {
218 global $username, $attachments, $attachment_dir;
220 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
222 foreach ($attachments as $info) {
223 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
224 if (file_exists($attached_file)) {
225 unlink($attached_file);
229 $attachments = array();
232 function formatRecipientString($recipients, $item ) {
233 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, $echo_more, $echo_less, $show_more, $show_more_bcc;
238 if (isset ($recipients[0]) && trim($recipients[0])) {
244 $show = "&show_more=1&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
245 $show_n = "&show_more=0&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
248 $show = "&show_more=$show_more&show_more_cc=1&show_more_bcc=$show_more_bcc";
249 $show_n = "&show_more=$show_more&show_more_cc=0&show_more_bcc=$show_more_bcc";
250 $show_more = $show_more_cc;
253 $show = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=1";
254 $show_n = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=0";
255 $show_more = $show_more_bcc;
261 while ($i < count($ary)) {
262 $ary[$i] = htmlspecialchars(decodeHeader($ary[$i]));
263 $url_string .= $ary[$i];
265 $string = "$string<BR>$ary[$i]";
267 $string = "$ary[$i]";
271 if (count($ary) > 1) {
272 if ($show_more == false) {
274 /* From a search... */
275 $string .= ' (<A HREF="' . $base_uri .
276 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
277 if (isset($where) && isset($what)) {
278 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show\">$echo_more</A>)";
280 $string .= "sort=$sort&startMessage=$startMessage"."$show\">$echo_more</A>)";
284 } else if ($i == 1) {
285 /* From a search... */
286 $string .= ' (<A HREF="' . $base_uri .
287 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
288 if (isset($where) && isset($what)) {
289 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show_n\">$echo_less</A>)";
291 $string .= "sort=$sort&startMessage=$startMessage"."$show_n\">$echo_less</A>)";
301 $url_string = urlencode($url_string);
303 $result['str'] = $string;
304 $result['url_str'] = $url_string;
311 * Main of read_boby.php --------------------------------------------------
320 if ( isset( $mailbox ) ) {
321 $mailbox = urldecode( $mailbox );
323 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
324 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
329 * The following code sets necesarry stuff for the MDN thing
331 if( $default_use_mdn &&
332 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
334 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
335 $flags = sqimap_get_flags ($imapConnection, $passed_id);
336 $FirstTimeSee = !(in_array( 'Seen', $flags ));
339 displayPageHeader($color, $mailbox);
343 * The following code shows the header of the message and then exit
345 if (isset($view_hdr)) {
346 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
349 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
350 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>" . _("Viewing Full Header") . '</B> - '.
351 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
352 if (isset($where) && isset($what)) {
353 // Got here from a search
354 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
356 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
358 echo _("View message") . "</a></b></td></tr></table>\n" .
359 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
363 for ($i=1; $i < count($read); $i++
) {
364 $line = htmlspecialchars($read[$i]);
365 if (eregi("^>", $line)) {
367 $first[$i] = ' ';
369 } else if (eregi("^[ |\t]", $line)) {
372 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
373 $first[$i] = $regs[1] . ':';
374 $second[$i] = $regs[2];
377 $second[$i] = trim($line);
381 for ($i=0; $i < count($second); $i = $j) {
382 if (isset($first[$i])) {
385 if (isset($second[$i])) {
386 $s = nl2br($second[$i]);
389 while (($first[$j] == '') && ($j < count($first))) {
390 $s .= ' ' . nl2br($second[$j]);
395 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
398 echo "</td></tr></table>\n" .
400 sqimap_logout($imapConnection);
405 $currentArrayIndex = $passed_id;
407 $currentArrayIndex = -1;
410 for ($i = 0; $i < count($msgs); $i++
) {
411 if ($msgs[$i]['ID'] == $passed_id) {
412 $msgs[$i]['FLAG_SEEN'] = true;
416 // $message contains all information about the message
417 // including header and body
418 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
420 /** translate the subject and mailbox into url-able text **/
421 $url_subj = urlencode(trim($message->header
->subject
));
422 $urlMailbox = urlencode($mailbox);
424 if (isset($message->header
->replyto
)) {
425 $url_replyto = urlencode($message->header
->replyto
);
428 $url_replytoall = $url_replyto;
430 // If we are replying to all, then find all other addresses and
431 // add them to the list. Remove duplicates.
432 // This is somewhat messy, so I'll explain:
433 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
434 $url_replytoall_extra_addrs = array_merge(
435 array($message->header
->from
),
436 $message->header
->to
,
440 // 2) Make one big string out of them
441 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
443 // 3) Parse that into an array of addresses
444 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
446 // 4) Make them unique -- weed out duplicates
447 // (Coded for PHP 4.0.0)
448 $url_replytoall_extra_addrs =
449 array_keys(array_flip($url_replytoall_extra_addrs));
451 // 5) Remove the addresses we'll be sending the message 'to'
452 $url_replytoall_avoid_addrs = '';
453 if (isset($message->header
->replyto
)) {
454 $url_replytoall_avoid_addrs = $message->header
->replyto
;
457 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
458 foreach ($url_replytoall_avoid_addrs as $addr) {
459 RemoveAddress($url_replytoall_extra_addrs, $addr);
462 // 6) Remove our identities from the CC list (they still can be in the
463 // TO list) only if $include_self_reply_all is turned off
464 if (!$include_self_reply_all) {
465 RemoveAddress($url_replytoall_extra_addrs,
466 getPref($data_dir, $username, 'email_address'));
467 $idents = getPref($data_dir, $username, 'identities');
468 if ($idents != '' && $idents > 1) {
469 for ($i = 1; $i < $idents; $i ++
) {
470 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
471 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
476 // 7) Smoosh back into one nice line
477 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
480 $url_replytoallcc = urlencode($url_replytoallcc);
482 $dateString = getLongDateString($message->header
->date
);
484 // What do we reply to -- text only, if possible
485 $ent_num = findDisplayEntity($message);
487 /** TEXT STRINGS DEFINITIONS **/
488 $echo_more = _("more");
489 $echo_less = _("less");
491 if (!isset($show_more_cc)) {
492 $show_more_cc = FALSE;
495 if (!isset($show_more_bcc)) {
496 $show_more_bcc = FALSE;
499 /** FORMAT THE TO STRING **/
500 $to = formatRecipientString($message->header
->to
, "to");
501 $to_string = $to['str'];
502 $url_to_string = $to['url_str'];
505 /** FORMAT THE CC STRING **/
507 $cc = formatRecipientString($message->header
->cc
, "cc");
508 $cc_string = $cc['str'];
509 $url_cc_string = $cc['url_str'];
511 /** FORMAT THE BCC STRING **/
513 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
514 $bcc_string = $bcc['str'];
515 $url_bcc_string = $bcc['url_str'];
517 if ($default_use_priority) {
518 $priority_level = substr($message->header
->priority
,0,1);
520 switch($priority_level) {
521 /* check for a higher then normal priority. */
524 $priority_string = _("High");
527 /* check for a lower then normal priority. */
530 $priority_string = _("Low");
533 /* check for a normal priority. */
536 $priority_level = '3';
537 $priority_string = _("Normal");
543 /** make sure everything will display in HTML format **/
544 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
545 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
547 do_hook('read_body_top');
549 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
550 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
551 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
553 '<TD ALIGN="LEFT" WIDTH="33%">' .
555 '<A HREF="' . $base_uri . 'src/';
557 if ($where && $what) {
561 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
563 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
565 echo _("Message List") .
566 '</A> | ' .
567 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
568 if ($where && $what) {
569 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
571 echo "sort=$sort&startMessage=$startMessage\">";
573 echo _("Delete") . '</A> ';
574 if (($mailbox == $draft_folder) && ($save_as_draft)) {
575 echo '| <A HREF="' . $base_uri .
576 "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" . '"';
577 if ($compose_new_win == '1') {
578 echo 'TARGET="compose_window" onClick="comp_in_new()"';
581 _("Resume Draft") . '</a>';
584 echo ' ' .
587 '<TD WIDTH="33%" ALIGN="CENTER">' .
590 if ( !($where && $what) ) {
592 if ($currentArrayIndex == -1) {
593 echo 'Previous | Next';
595 $prev = findPreviousMessage();
596 $next = findNextMessage();
599 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
601 echo _("Previous") . ' | ';
605 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
613 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
615 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
616 ($default_use_priority?
"mailprio=$priority_level&":'')
617 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
618 if ($compose_new_win == '1') {
619 echo 'TARGET="compose_window" onClick="comp_in_new()"';
623 '</A> | ' .
624 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
625 ($default_use_priority?
"mailprio=$priority_level&":'').
626 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
627 if ($compose_new_win == '1') {
628 echo 'TARGET="compose_window" onClick="comp_in_new()"';
632 '</A> | ' .
633 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
634 ($default_use_priority?
"mailprio=$priority_level&":'').
635 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
636 if ($compose_new_win == '1') {
637 echo 'TARGET="compose_window" onClick="comp_in_new()"';
647 '<TR><TD WIDTH="100%">' .
648 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
652 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
654 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
655 "<B>$subject</B> \n" .
657 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
658 '" ALIGN=right VALIGN=top NOWRAP><small>'.
659 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
661 /* From a search... */
662 if ($where && $what) {
663 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
664 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
666 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
667 _("View Full Header") . "</A>\n";
670 /* Output the printer friendly link if we are in subtle mode. */
671 if ($pf_subtle_link) {
672 echo printer_friendly_link(true);
675 do_hook("read_body_header_right");
676 echo '</small></TD>' .
681 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
683 '</TD><TD BGCOLOR="' . $color[0] . '">' .
684 "<B>$from_name</B> \n" .
689 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
691 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
692 "<B>$dateString</B> \n" .
698 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
700 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
701 "<B>$to_string</B> \n" .
705 if (isset($cc_string) && $cc_string <> '') {
707 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
709 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
710 "<B>$cc_string</B> " .
716 if (isset($bcc_string) && $bcc_string <> '') {
718 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
720 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
721 "<B>$bcc_string</B> " .
725 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
727 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
728 _("Priority") . ': '.
729 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
730 "<B>$priority_string</B> " .
735 if ($show_xmailer_default) {
736 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
737 $response, $readmessage);
738 $mailer = substr($read[1], strpos($read[1], " "));
741 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
743 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
744 "<B>$mailer</B> " .
750 /* Output the printer friendly link if we are not in subtle mode. */
751 if (!$pf_subtle_link) {
752 echo printer_friendly_link(true);
755 if ($default_use_mdn) {
756 if ($mdn_user_support) {
758 // debug gives you the capability to remove mdn-flags
759 // $MDNDebug = false;
760 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
761 $response, $readmessage);
762 $MDN_to = substr($read[1], strpos($read[1], ' '));
763 $MDN_flag_present = false;
765 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
766 $response, $readmessage);
768 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
771 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
773 if ( $MDN_flag_present && $supportMDN) {
774 $sendreceipt = 'removeMDN';
775 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
780 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
781 _("Read receipt") . ': ' .
782 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
785 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
791 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
792 _("Read receipt") . ': ' .
793 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
794 '<B>'._("send").'</B>'.
801 } // when deleted or draft flag is set don't offer to send a MDN response
802 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
804 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
805 _("Read receipt") . ': '.
806 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
807 '<B>' . _("requested") . "</B>" .
811 // if no MDNsupport don't use the annoying popup messages
812 else if ( !$FirstTimeSee ) {
813 $sendreceipt = 'send';
814 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
816 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
817 _("Read receipt") . ': ' .
818 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
819 '<B>' . _("requested") .
820 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
826 $sendreceipt = 'send';
827 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
828 if ($javascript_on) {
829 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
831 " if (window.confirm(\"" .
832 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
834 " window.location=($url); \n" .
835 ' window.reload()' . "\n" .
841 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
842 _("Read receipt") . ': ' .
843 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
844 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
845 _("Send read receipt now") . '] </a>' ." \n" .
852 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
853 } else if ( $sendreceipt == 'send' ) {
854 if ( !$MDN_flag_present) {
855 if (isset($identity) ) {
856 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
858 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
861 $final_recipient = trim($final_recipient);
862 if ($final_recipient == '' ) {
863 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
866 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
867 ToggleMDNflag( true);
870 $sendreceipt = 'removeMDN';
871 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
874 if ($MDNDebug && $supportMDN) {
876 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
877 " "._("Read receipt").": \n".
878 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
879 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
885 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
886 " "._("Read receipt").": \n".
887 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
888 ' <B>'._("send").'</B>'. "\n" .
895 elseif ($sendreceipt == 'removeMDN' ) {
896 ToggleMDNflag ( false );
898 $sendreceipt = 'send';
899 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
901 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
902 _("Read receipt") . ': ' .
903 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
904 '<B>' . _("requested") .
905 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
914 do_hook('read_body_header');
921 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
922 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
924 formatBody($imapConnection, $message, $color, $wrap_at).
925 '</TD></TR></TABLE>' .
926 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
927 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
930 /* show attached images inline -- if pref'fed so */
931 if (($attachment_common_show_images) &&
932 is_array($attachment_common_show_images_list)) {
934 foreach ($attachment_common_show_images_list as $img) {
935 $imgurl = '../src/download.php' .
937 'passed_id=' . urlencode($img['passed_id']) .
938 '&mailbox=' . urlencode($mailbox) .
939 '&passed_ent_id=' . urlencode($img['ent_id']) .
940 '&absolute_dl=true';
942 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
945 "<img src=\"$imgurl\">\n" .
954 do_hook('read_body_bottom');
955 do_hook('html_bottom');
956 sqimap_logout($imapConnection);