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";
198 $newAttachment['session']=-1;
199 $attachments[] = $newAttachment;
200 $MDN_to = trim($recipient);
203 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3, -1) );
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 $rem_attachments = array();
223 foreach ($attachments as $info) {
224 if ($info->session
== -1) {
225 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
226 if (file_exists($attached_file)) {
227 unlink($attached_file);
230 $rem_attachments[] = $info;
233 $attachments = rem_attachments
;
236 function formatRecipientString($recipients, $item ) {
237 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
242 if (isset ($recipients[0]) && trim($recipients[0])) {
248 $show = "&show_more=1&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
249 $show_n = "&show_more=0&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
252 $show = "&show_more=$show_more&show_more_cc=1&show_more_bcc=$show_more_bcc";
253 $show_n = "&show_more=$show_more&show_more_cc=0&show_more_bcc=$show_more_bcc";
254 $show_more = $show_more_cc;
257 $show = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=1";
258 $show_n = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=0";
259 $show_more = $show_more_bcc;
265 while ($i < count($ary)) {
266 $ary[$i] = htmlspecialchars(decodeHeader($ary[$i]));
267 $url_string .= $ary[$i];
269 $string = "$string<BR>$ary[$i]";
271 $string = "$ary[$i]";
275 if (count($ary) > 1) {
276 if ($show_more == false) {
278 /* From a search... */
279 $string .= ' (<A HREF="' . $base_uri .
280 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
281 if (isset($where) && isset($what)) {
282 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show\">$echo_more</A>)";
284 $string .= "sort=$sort&startMessage=$startMessage"."$show\">$echo_more</A>)";
288 } else if ($i == 1) {
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_n\">$echo_less</A>)";
295 $string .= "sort=$sort&startMessage=$startMessage"."$show_n\">$echo_less</A>)";
305 $url_string = urlencode($url_string);
307 $result['str'] = $string;
308 $result['url_str'] = $url_string;
315 * Main of read_boby.php --------------------------------------------------
324 if ( isset( $mailbox ) ) {
325 $mailbox = urldecode( $mailbox );
327 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
328 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
333 * The following code sets necesarry stuff for the MDN thing
335 if( $default_use_mdn &&
336 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
338 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
339 $flags = sqimap_get_flags ($imapConnection, $passed_id);
340 $FirstTimeSee = !(in_array( 'Seen', $flags ));
343 displayPageHeader($color, $mailbox);
347 * The following code shows the header of the message and then exit
349 if (isset($view_hdr)) {
350 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
353 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
354 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>" . _("Viewing Full Header") . '</B> - '.
355 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
356 if (isset($where) && isset($what)) {
357 // Got here from a search
358 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
360 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
362 echo _("View message") . "</a></b></td></tr></table>\n" .
363 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
367 for ($i=1; $i < count($read); $i++
) {
368 $line = htmlspecialchars($read[$i]);
369 if (eregi("^>", $line)) {
371 $first[$i] = ' ';
373 } else if (eregi("^[ |\t]", $line)) {
376 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
377 $first[$i] = $regs[1] . ':';
378 $second[$i] = $regs[2];
381 $second[$i] = trim($line);
385 for ($i=0; $i < count($second); $i = $j) {
386 if (isset($first[$i])) {
389 if (isset($second[$i])) {
390 $s = nl2br($second[$i]);
393 while (($first[$j] == '') && ($j < count($first))) {
394 $s .= ' ' . nl2br($second[$j]);
399 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
402 echo "</td></tr></table>\n" .
404 sqimap_logout($imapConnection);
409 $currentArrayIndex = $passed_id;
411 $currentArrayIndex = -1;
414 for ($i = 0; $i < count($msgs); $i++
) {
415 if ($msgs[$i]['ID'] == $passed_id) {
416 $msgs[$i]['FLAG_SEEN'] = true;
420 // $message contains all information about the message
421 // including header and body
422 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
424 /** translate the subject and mailbox into url-able text **/
425 $url_subj = urlencode(trim($message->header
->subject
));
426 $urlMailbox = urlencode($mailbox);
428 if (isset($message->header
->replyto
)) {
429 $url_replyto = urlencode($message->header
->replyto
);
432 $url_replytoall = $url_replyto;
434 // If we are replying to all, then find all other addresses and
435 // add them to the list. Remove duplicates.
436 // This is somewhat messy, so I'll explain:
437 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
438 $url_replytoall_extra_addrs = array_merge(
439 array($message->header
->from
),
440 $message->header
->to
,
444 // 2) Make one big string out of them
445 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
447 // 3) Parse that into an array of addresses
448 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
450 // 4) Make them unique -- weed out duplicates
451 // (Coded for PHP 4.0.0)
452 $url_replytoall_extra_addrs =
453 array_keys(array_flip($url_replytoall_extra_addrs));
455 // 5) Remove the addresses we'll be sending the message 'to'
456 $url_replytoall_avoid_addrs = '';
457 if (isset($message->header
->replyto
)) {
458 $url_replytoall_avoid_addrs = $message->header
->replyto
;
461 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
462 foreach ($url_replytoall_avoid_addrs as $addr) {
463 RemoveAddress($url_replytoall_extra_addrs, $addr);
466 // 6) Remove our identities from the CC list (they still can be in the
467 // TO list) only if $include_self_reply_all is turned off
468 if (!$include_self_reply_all) {
469 RemoveAddress($url_replytoall_extra_addrs,
470 getPref($data_dir, $username, 'email_address'));
471 $idents = getPref($data_dir, $username, 'identities');
472 if ($idents != '' && $idents > 1) {
473 for ($i = 1; $i < $idents; $i ++
) {
474 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
475 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
480 // 7) Smoosh back into one nice line
481 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
484 $url_replytoallcc = urlencode($url_replytoallcc);
486 $dateString = getLongDateString($message->header
->date
);
488 // What do we reply to -- text only, if possible
489 $ent_num = findDisplayEntity($message);
491 /** TEXT STRINGS DEFINITIONS **/
492 $echo_more = _("more");
493 $echo_less = _("less");
495 if (!isset($show_more_cc)) {
496 $show_more_cc = FALSE;
499 if (!isset($show_more_bcc)) {
500 $show_more_bcc = FALSE;
503 /** FORMAT THE TO STRING **/
504 $to = formatRecipientString($message->header
->to
, "to");
505 $to_string = $to['str'];
506 $url_to_string = $to['url_str'];
509 /** FORMAT THE CC STRING **/
511 $cc = formatRecipientString($message->header
->cc
, "cc");
512 $cc_string = $cc['str'];
513 $url_cc_string = $cc['url_str'];
515 /** FORMAT THE BCC STRING **/
517 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
518 $bcc_string = $bcc['str'];
519 $url_bcc_string = $bcc['url_str'];
521 if ($default_use_priority) {
522 $priority_level = substr($message->header
->priority
,0,1);
524 switch($priority_level) {
525 /* check for a higher then normal priority. */
528 $priority_string = _("High");
531 /* check for a lower then normal priority. */
534 $priority_string = _("Low");
537 /* check for a normal priority. */
540 $priority_level = '3';
541 $priority_string = _("Normal");
547 /** make sure everything will display in HTML format **/
548 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
549 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
551 do_hook('read_body_top');
553 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
554 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
555 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
557 '<TD ALIGN="LEFT" WIDTH="33%">' .
559 '<A HREF="' . $base_uri . 'src/';
561 if ($where && $what) {
565 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
567 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
569 echo _("Message List") .
570 '</A> | ' .
571 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
572 if ($where && $what) {
573 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
575 echo "sort=$sort&startMessage=$startMessage\">";
577 echo _("Delete") . '</A> ';
578 if (($mailbox == $draft_folder) && ($save_as_draft)) {
579 echo '| <A HREF="' . $base_uri .
580 "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" . '"';
581 if ($compose_new_win == '1') {
582 echo 'TARGET="compose_window" onClick="comp_in_new()"';
585 _("Resume Draft") . '</a>';
588 echo ' ' .
591 '<TD WIDTH="33%" ALIGN="CENTER">' .
594 if ( !($where && $what) ) {
596 if ($currentArrayIndex == -1) {
597 echo 'Previous | Next';
599 $prev = findPreviousMessage();
600 $next = findNextMessage();
603 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
605 echo _("Previous") . ' | ';
609 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
617 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
619 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
620 ($default_use_priority?
"mailprio=$priority_level&":'')
621 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
622 if ($compose_new_win == '1') {
623 echo 'TARGET="compose_window" onClick="comp_in_new()"';
627 '</A> | ' .
628 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
629 ($default_use_priority?
"mailprio=$priority_level&":'').
630 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
631 if ($compose_new_win == '1') {
632 echo 'TARGET="compose_window" onClick="comp_in_new()"';
636 '</A> | ' .
637 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
638 ($default_use_priority?
"mailprio=$priority_level&":'').
639 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
640 if ($compose_new_win == '1') {
641 echo 'TARGET="compose_window" onClick="comp_in_new()"';
651 '<TR><TD WIDTH="100%">' .
652 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
656 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
658 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
659 "<B>$subject</B> \n" .
661 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
662 '" ALIGN=right VALIGN=top NOWRAP><small>'.
663 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
665 /* From a search... */
666 if ($where && $what) {
667 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
668 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
670 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
671 _("View Full Header") . "</A>\n";
674 /* Output the printer friendly link if we are in subtle mode. */
675 if ($pf_subtle_link) {
676 echo printer_friendly_link(true);
679 do_hook("read_body_header_right");
680 echo '</small></TD>' .
685 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
687 '</TD><TD BGCOLOR="' . $color[0] . '">' .
688 "<B>$from_name</B> \n" .
693 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
695 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
696 "<B>$dateString</B> \n" .
702 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
704 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
705 "<B>$to_string</B> \n" .
709 if (isset($cc_string) && $cc_string <> '') {
711 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
713 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
714 "<B>$cc_string</B> " .
720 if (isset($bcc_string) && $bcc_string <> '') {
722 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
724 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
725 "<B>$bcc_string</B> " .
729 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
731 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
732 _("Priority") . ': '.
733 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
734 "<B>$priority_string</B> " .
739 if ($show_xmailer_default) {
740 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
741 $response, $readmessage);
742 $mailer = substr($read[1], strpos($read[1], " "));
745 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
747 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
748 "<B>$mailer</B> " .
754 /* Output the printer friendly link if we are not in subtle mode. */
755 if (!$pf_subtle_link) {
756 echo printer_friendly_link(true);
759 if ($default_use_mdn) {
760 if ($mdn_user_support) {
762 // debug gives you the capability to remove mdn-flags
763 // $MDNDebug = false;
764 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
765 $response, $readmessage);
766 $MDN_to = substr($read[1], strpos($read[1], ' '));
767 $MDN_flag_present = false;
769 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
770 $response, $readmessage);
772 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
775 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
777 if ( $MDN_flag_present && $supportMDN) {
778 $sendreceipt = 'removeMDN';
779 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
784 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
785 _("Read receipt") . ': ' .
786 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
789 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
795 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
796 _("Read receipt") . ': ' .
797 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
798 '<B>'._("send").'</B>'.
805 } // when deleted or draft flag is set don't offer to send a MDN response
806 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
808 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
809 _("Read receipt") . ': '.
810 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
811 '<B>' . _("requested") . "</B>" .
815 // if no MDNsupport don't use the annoying popup messages
816 else if ( !$FirstTimeSee ) {
817 $sendreceipt = 'send';
818 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
820 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
821 _("Read receipt") . ': ' .
822 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
823 '<B>' . _("requested") .
824 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
830 $sendreceipt = 'send';
831 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
832 if ($javascript_on) {
833 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
835 " if (window.confirm(\"" .
836 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
838 " window.location=($url); \n" .
839 ' window.reload()' . "\n" .
845 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
846 _("Read receipt") . ': ' .
847 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
848 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
849 _("Send read receipt now") . '] </a>' ." \n" .
856 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
857 } else if ( $sendreceipt == 'send' ) {
858 if ( !$MDN_flag_present) {
859 if (isset($identity) ) {
860 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
862 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
865 $final_recipient = trim($final_recipient);
866 if ($final_recipient == '' ) {
867 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
870 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
871 ToggleMDNflag( true);
874 $sendreceipt = 'removeMDN';
875 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
878 if ($MDNDebug && $supportMDN) {
880 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
881 " "._("Read receipt").": \n".
882 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
883 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
889 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
890 " "._("Read receipt").": \n".
891 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
892 ' <B>'._("send").'</B>'. "\n" .
899 elseif ($sendreceipt == 'removeMDN' ) {
900 ToggleMDNflag ( false );
902 $sendreceipt = 'send';
903 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
905 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
906 _("Read receipt") . ': ' .
907 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
908 '<B>' . _("requested") .
909 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
918 do_hook('read_body_header');
925 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
926 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
928 formatBody($imapConnection, $message, $color, $wrap_at).
929 '</TD></TR></TABLE>' .
930 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
931 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
934 /* show attached images inline -- if pref'fed so */
935 if (($attachment_common_show_images) &&
936 is_array($attachment_common_show_images_list)) {
938 foreach ($attachment_common_show_images_list as $img) {
939 $imgurl = '../src/download.php' .
941 'passed_id=' . urlencode($img['passed_id']) .
942 '&mailbox=' . urlencode($mailbox) .
943 '&passed_ent_id=' . urlencode($img['ent_id']) .
944 '&absolute_dl=true';
946 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
949 "<img src=\"$imgurl\">\n" .
958 do_hook('read_body_bottom');
959 do_hook('html_bottom');
960 sqimap_logout($imapConnection);