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 $allow_thread_sort, $allow_server_sort,
34 if ($allow_thread_sort == true ||
$allow_server_sort == true) {
35 reset($server_sort_array);
36 while(list($key, $value) = each ($server_sort_array)) {
37 if ($currentArrayIndex == $value) {
38 if ($key == (count($server_sort_array) -1)) {
42 $result = $server_sort_array[$key +
1];
48 elseif ($sort == 6 && $allow_server_sort != true && $allow_thread_sort != true) {
49 if ($currentArrayIndex != 1) {
50 $result = $currentArrayIndex - 1;
53 elseif ($allow_server_sort != true && $allow_thread_sort != true) {
54 if (!is_array($msort)) {
57 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
58 if ($currentArrayIndex == $msgs[$key]['ID']) {
62 $result = $msgs[$key]['ID'];
70 /** Removes just one address from the list of addresses. */
71 function RemoveAddress(&$addr_list, $addr) {
73 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
74 unset($addr_list[$key_to_delete]);
79 /** returns the index of the previous message from the array. */
80 function findPreviousMessage() {
81 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
82 $mailbox, $data_dir, $username, $allow_thread_sort,
83 $allow_server_sort, $server_sort_array;
85 if ($allow_thread_sort == true ||
$allow_server_sort == TRUE) {
86 reset($server_sort_array);
87 while(list($key, $value) = each ($server_sort_array)) {
88 if ($currentArrayIndex == $value) {
93 $result = $server_sort_array[$key -1];
98 elseif ($sort == 6 && $allow_server_sort != TRUE && $allow_thread_sort != true) {
99 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
100 if ($currentArrayIndex != $numMessages) {
101 $result = $currentArrayIndex +
1;
104 elseif ($allow_thread_sort != true && $allow_server_sort != TRUE) {
105 if (!is_array($msort)) {
108 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
109 if ($currentArrayIndex == $msgs[$key]['ID']) {
113 $result = $msgs[$key]['ID'];
123 * Displays a link to a page where the message is displayed more
124 * "printer friendly".
126 function printer_friendly_link() {
127 global $passed_id, $mailbox, $ent_num, $color,
131 if (strlen(trim($mailbox)) < 1) {
135 $params = '?passed_ent_id=' . $ent_num .
136 '&mailbox=' . urlencode($mailbox) .
137 '&passed_id=' . $passed_id;
139 $print_text = _("View Printable Version");
141 if (!$pf_subtle_link) {
142 /* The link is large, on the bottom of the header panel. */
143 $result = '<tr bgcolor="' . $color[0] . '">' .
144 '<td class="medText" align="right" valign="top">' .
146 '</td><td class="medText" valign="top" colspan="2">'."\n";
148 /* The link is subtle, below "view full header". */
152 /* Output the link. */
153 if ($javascript_on) {
154 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
156 " function printFormat() {\n" .
157 ' window.open("../src/printer_friendly_main.php' .
158 $params . '","Print","width=800,height=600");' . "\n".
162 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
164 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
165 "$params\">$print_text</A>\n";
168 if (!$pf_subtle_link) {
169 /* The link is large, on the bottom of the header panel. */
170 $result .= '</td></tr>' . "\n";
176 function ServerMDNSupport( $read ) {
177 /* escaping $ doesn't work -> \x36 */
178 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
182 function SendMDN ( $recipient , $sender) {
183 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
184 $version, $attachments, $identity, $data_dir, $passed_id;
186 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
187 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
191 $senton = getLongDateString( $header->date
);
192 $to_array = $header->to
;
194 foreach ($to_array as $line) {
198 $subject = $header->subject
;
199 $now = getLongDateString( time() );
201 $body = _("Your message") . "\r\n\r\n" .
202 "\t" . _("To:") . ' ' . $to . "\r\n" .
203 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
204 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
206 sprintf( _("Was displayed on %s"), $now );
210 $original_recipient = $to;
211 $original_message_id = $header->message_id
;
213 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
214 if ($original_recipient != '') {
215 $part2 .= "Original-Recipient : $original_recipient\r\n";
217 $final_recipient = $sender;
218 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
219 "Original-Message-ID : $original_message_id\r\n" .
220 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
223 $localfilename = GenerateRandomString(32, 'FILE', 7);
224 $full_localfilename = "$hashed_attachment_dir/$localfilename";
226 $fp = fopen( $full_localfilename, 'w');
227 fwrite ($fp, $part2);
230 $newAttachment = array();
231 $newAttachment['localfilename'] = $localfilename;
232 $newAttachment['type'] = "message/disposition-notification";
233 $newAttachment['session']=-1;
234 $attachments[] = $newAttachment;
235 $MDN_to = trim($recipient);
238 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3, -1) );
242 function ToggleMDNflag ( $set ) {
243 global $imapConnection, $passed_id, $mailbox;
244 sqimap_mailbox_select($imapConnection, $mailbox);
247 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
248 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
252 function ClearAttachments() {
253 global $username, $attachments, $attachment_dir;
255 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
257 $rem_attachments = array();
258 foreach ($attachments as $info) {
259 if ($info->session
== -1) {
260 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
261 if (file_exists($attached_file)) {
262 unlink($attached_file);
265 $rem_attachments[] = $info;
268 $attachments = rem_attachments
;
271 function formatRecipientString($recipients, $item ) {
272 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc, $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
277 if (isset ($recipients[0]) && trim($recipients[0])) {
283 $show = "&show_more=1&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
284 $show_n = "&show_more=0&show_more_cc=$show_more_cc&show_more_bcc=$show_more_bcc";
287 $show = "&show_more=$show_more&show_more_cc=1&show_more_bcc=$show_more_bcc";
288 $show_n = "&show_more=$show_more&show_more_cc=0&show_more_bcc=$show_more_bcc";
289 $show_more = $show_more_cc;
292 $show = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=1";
293 $show_n = "&show_more=$show_more&show_more_cc=$show_more_cc&show_more_bcc=0";
294 $show_more = $show_more_bcc;
300 while ($i < count($ary)) {
301 $ary[$i] = htmlspecialchars(decodeHeader($ary[$i]));
302 $url_string .= $ary[$i];
304 $string = "$string<BR>$ary[$i]";
306 $string = "$ary[$i]";
310 if (count($ary) > 1) {
311 if ($show_more == false) {
313 /* From a search... */
314 $string .= ' (<A HREF="' . $base_uri .
315 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
316 if (isset($where) && isset($what)) {
317 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show\">$echo_more</A>)";
319 $string .= "sort=$sort&startMessage=$startMessage"."$show\">$echo_more</A>)";
323 } else if ($i == 1) {
324 /* From a search... */
325 $string .= ' (<A HREF="' . $base_uri .
326 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
327 if (isset($where) && isset($what)) {
328 $string .= 'what=' . urlencode($what)."&where=".urlencode($where)."$show_n\">$echo_less</A>)";
330 $string .= "sort=$sort&startMessage=$startMessage"."$show_n\">$echo_less</A>)";
340 $url_string = urlencode($url_string);
342 $result['str'] = $string;
343 $result['url_str'] = $url_string;
350 * Main of read_boby.php --------------------------------------------------
359 if ( isset( $mailbox ) ) {
360 $mailbox = urldecode( $mailbox );
362 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
363 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
368 * The following code sets necesarry stuff for the MDN thing
370 if( $default_use_mdn &&
371 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
373 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
374 $flags = sqimap_get_flags ($imapConnection, $passed_id);
375 $FirstTimeSee = !(in_array( 'Seen', $flags ));
378 displayPageHeader($color, $mailbox);
382 * The following code shows the header of the message and then exit
384 if (isset($view_hdr)) {
385 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
388 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
389 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>" . _("Viewing Full Header") . '</B> - '.
390 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
391 if (isset($where) && isset($what)) {
392 // Got here from a search
393 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
395 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
397 echo _("View message") . "</a></b></td></tr></table>\n" .
398 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
402 for ($i=1; $i < count($read); $i++
) {
403 $line = htmlspecialchars($read[$i]);
404 if (eregi("^>", $line)) {
406 $first[$i] = ' ';
408 } else if (eregi("^[ |\t]", $line)) {
411 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
412 $first[$i] = $regs[1] . ':';
413 $second[$i] = $regs[2];
416 $second[$i] = trim($line);
420 for ($i=0; $i < count($second); $i = $j) {
421 if (isset($first[$i])) {
424 if (isset($second[$i])) {
425 $s = nl2br($second[$i]);
428 while (($first[$j] == '') && ($j < count($first))) {
429 $s .= ' ' . nl2br($second[$j]);
434 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
437 echo "</td></tr></table>\n" .
439 sqimap_logout($imapConnection);
444 $currentArrayIndex = $passed_id;
446 $currentArrayIndex = -1;
449 for ($i = 0; $i < count($msgs); $i++
) {
450 if ($msgs[$i]['ID'] == $passed_id) {
451 $msgs[$i]['FLAG_SEEN'] = true;
455 // $message contains all information about the message
456 // including header and body
457 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
459 /** translate the subject and mailbox into url-able text **/
460 $url_subj = urlencode(trim($message->header
->subject
));
461 $urlMailbox = urlencode($mailbox);
463 if (isset($message->header
->replyto
)) {
464 $url_replyto = urlencode($message->header
->replyto
);
467 $url_replytoall = $url_replyto;
469 // If we are replying to all, then find all other addresses and
470 // add them to the list. Remove duplicates.
471 // This is somewhat messy, so I'll explain:
472 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
473 $url_replytoall_extra_addrs = array_merge(
474 array($message->header
->from
),
475 $message->header
->to
,
479 // 2) Make one big string out of them
480 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
482 // 3) Parse that into an array of addresses
483 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
485 // 4) Make them unique -- weed out duplicates
486 // (Coded for PHP 4.0.0)
487 $url_replytoall_extra_addrs =
488 array_keys(array_flip($url_replytoall_extra_addrs));
490 // 5) Remove the addresses we'll be sending the message 'to'
491 $url_replytoall_avoid_addrs = '';
492 if (isset($message->header
->replyto
)) {
493 $url_replytoall_avoid_addrs = $message->header
->replyto
;
496 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
497 foreach ($url_replytoall_avoid_addrs as $addr) {
498 RemoveAddress($url_replytoall_extra_addrs, $addr);
501 // 6) Remove our identities from the CC list (they still can be in the
502 // TO list) only if $include_self_reply_all is turned off
503 if (!$include_self_reply_all) {
504 RemoveAddress($url_replytoall_extra_addrs,
505 getPref($data_dir, $username, 'email_address'));
506 $idents = getPref($data_dir, $username, 'identities');
507 if ($idents != '' && $idents > 1) {
508 for ($i = 1; $i < $idents; $i ++
) {
509 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
510 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
515 // 7) Smoosh back into one nice line
516 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
519 $url_replytoallcc = urlencode($url_replytoallcc);
521 $dateString = getLongDateString($message->header
->date
);
523 // What do we reply to -- text only, if possible
524 $ent_num = findDisplayEntity($message);
526 /** TEXT STRINGS DEFINITIONS **/
527 $echo_more = _("more");
528 $echo_less = _("less");
530 if (!isset($show_more_cc)) {
531 $show_more_cc = FALSE;
534 if (!isset($show_more_bcc)) {
535 $show_more_bcc = FALSE;
538 /** FORMAT THE TO STRING **/
539 $to = formatRecipientString($message->header
->to
, "to");
540 $to_string = $to['str'];
541 $url_to_string = $to['url_str'];
544 /** FORMAT THE CC STRING **/
546 $cc = formatRecipientString($message->header
->cc
, "cc");
547 $cc_string = $cc['str'];
548 $url_cc_string = $cc['url_str'];
550 /** FORMAT THE BCC STRING **/
552 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
553 $bcc_string = $bcc['str'];
554 $url_bcc_string = $bcc['url_str'];
556 if ($default_use_priority) {
557 $priority_level = substr($message->header
->priority
,0,1);
559 switch($priority_level) {
560 /* check for a higher then normal priority. */
563 $priority_string = _("High");
566 /* check for a lower then normal priority. */
569 $priority_string = _("Low");
572 /* check for a normal priority. */
575 $priority_level = '3';
576 $priority_string = _("Normal");
582 /** make sure everything will display in HTML format **/
583 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
584 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
586 $idents = getPref($data_dir, $username, 'identities');
587 if (!empty($idents) && $idents > 1) {
588 for ($i = 1; $i < $idents; $i++
) {
589 if (htmlspecialchars('"' . encodeHeader(getPref($data_dir, $username, 'full_name' . $i)) .
590 '" <' . getPref($data_dir, $username, 'email_address' . $i) . '>') == $from_name) {
597 do_hook('read_body_top');
599 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
600 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
601 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
603 '<TD ALIGN="LEFT" WIDTH="33%">' .
605 '<A HREF="' . $base_uri . 'src/';
607 if ($where && $what) {
611 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
613 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
615 echo _("Message List") .
616 '</A> | ' .
617 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
618 if ($where && $what) {
619 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
621 echo "sort=$sort&startMessage=$startMessage\">";
623 echo _("Delete") . '</A> ';
624 if (($mailbox == $draft_folder) && ($save_as_draft)) {
625 echo '| <A HREF="' . $base_uri .
626 "src/compose.php?mailbox=$mailbox&identity=$identity&send_to=$url_to_string&send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&subject=$url_subj&mailprio=$priority_level&draft_id=$passed_id&ent_num=$ent_num" . '"';
627 if ($compose_new_win == '1') {
628 echo ' TARGET="compose_window" onClick="comp_in_new()"';
631 _("Resume Draft") . '</a>';
633 if ($mailbox == $sent_folder) {
634 echo '| <A HREF="' . $base_uri .
635 "src/compose.php?mailbox=$mailbox&identity=$identity&send_to=$url_to_string&send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&subject=$url_subj&mailprio=$priority_level&draft_id=$passed_id&ent_num=$ent_num" . '"';
636 if ($compose_new_win == '1') {
637 echo ' TARGET="compose_window" onClick="comp_in_new()"';
640 _("Edit Message as New") . '</a>';
643 echo ' ' .
646 '<TD WIDTH="33%" ALIGN="CENTER">' .
649 if ( !($where && $what) ) {
650 if ($currentArrayIndex == -1) {
651 echo 'Previous | Next';
653 $prev = findPreviousMessage();
654 $next = findNextMessage();
657 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
659 echo _("Previous") . ' | ';
663 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
671 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
673 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
674 ($default_use_priority?
"mailprio=$priority_level&":'')
675 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
676 if ($compose_new_win == '1') {
677 echo 'TARGET="compose_window" onClick="comp_in_new()"';
681 '</A> | ' .
682 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
683 ($default_use_priority?
"mailprio=$priority_level&":'').
684 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
685 if ($compose_new_win == '1') {
686 echo 'TARGET="compose_window" onClick="comp_in_new()"';
690 '</A> | ' .
691 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
692 ($default_use_priority?
"mailprio=$priority_level&":'').
693 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
694 if ($compose_new_win == '1') {
695 echo 'TARGET="compose_window" onClick="comp_in_new()"';
705 '<TR><TD WIDTH="100%">' .
706 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
710 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
712 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
713 "<B>$subject</B> \n" .
715 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
716 '" ALIGN=right VALIGN=top NOWRAP><small>'.
717 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
719 /* From a search... */
720 if ($where && $what) {
721 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
722 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
724 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
725 _("View Full Header") . "</A>\n";
728 /* Output the printer friendly link if we are in subtle mode. */
729 if ($pf_subtle_link) {
730 echo printer_friendly_link(true);
733 do_hook("read_body_header_right");
734 echo '</small></TD>' .
739 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
741 '</TD><TD BGCOLOR="' . $color[0] . '">' .
742 "<B>$from_name</B> \n" .
747 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
749 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
750 "<B>$dateString</B> \n" .
756 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
758 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
759 "<B>$to_string</B> \n" .
763 if (isset($cc_string) && $cc_string <> '') {
765 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
767 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
768 "<B>$cc_string</B> " .
774 if (isset($bcc_string) && $bcc_string <> '') {
776 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
778 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
779 "<B>$bcc_string</B> " .
783 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
785 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
786 _("Priority") . ': '.
787 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
788 "<B>$priority_string</B> " .
793 if ($show_xmailer_default) {
794 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
795 $response, $readmessage);
796 $mailer = substr($read[1], strpos($read[1], " "));
799 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
801 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
802 "<B>$mailer</B> " .
808 /* Output the printer friendly link if we are not in subtle mode. */
809 if (!$pf_subtle_link) {
810 echo printer_friendly_link(true);
813 if ($default_use_mdn) {
814 if ($mdn_user_support) {
816 // debug gives you the capability to remove mdn-flags
817 // $MDNDebug = false;
818 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
819 $response, $readmessage);
820 $MDN_to = substr($read[1], strpos($read[1], ' '));
821 $MDN_flag_present = false;
823 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
824 $response, $readmessage);
826 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
829 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
831 if ( $MDN_flag_present && $supportMDN) {
832 $sendreceipt = 'removeMDN';
833 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
838 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
839 _("Read receipt") . ': ' .
840 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
843 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
849 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
850 _("Read receipt") . ': ' .
851 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
852 '<B>'._("send").'</B>'.
859 } // when deleted or draft flag is set don't offer to send a MDN response
860 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
862 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
863 _("Read receipt") . ': '.
864 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
865 '<B>' . _("requested") . "</B>" .
869 // if no MDNsupport don't use the annoying popup messages
870 else if ( !$FirstTimeSee ) {
871 $sendreceipt = 'send';
872 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
874 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
875 _("Read receipt") . ': ' .
876 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
877 '<B>' . _("requested") .
878 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
884 $sendreceipt = 'send';
885 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
886 if ($javascript_on) {
887 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
889 " if (window.confirm(\"" .
890 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
892 " window.location=($url); \n" .
893 ' window.reload()' . "\n" .
899 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
900 _("Read receipt") . ': ' .
901 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
902 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
903 _("Send read receipt now") . '] </a>' ." \n" .
910 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
911 } else if ( $sendreceipt == 'send' ) {
912 if ( !$MDN_flag_present) {
913 if (isset($identity) ) {
914 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
916 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
919 $final_recipient = trim($final_recipient);
920 if ($final_recipient == '' ) {
921 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
924 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
925 ToggleMDNflag( true);
928 $sendreceipt = 'removeMDN';
929 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
932 if ($MDNDebug && $supportMDN) {
934 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
935 " "._("Read receipt").": \n".
936 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
937 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
943 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
944 " "._("Read receipt").": \n".
945 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
946 ' <B>'._("send").'</B>'. "\n" .
953 elseif ($sendreceipt == 'removeMDN' ) {
954 ToggleMDNflag ( false );
956 $sendreceipt = 'send';
957 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
959 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
960 _("Read receipt") . ': ' .
961 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
962 '<B>' . _("requested") .
963 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
972 do_hook('read_body_header');
979 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
980 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
982 formatBody($imapConnection, $message, $color, $wrap_at).
983 '</TD></TR></TABLE>' .
984 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
985 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
988 /* show attached images inline -- if pref'fed so */
989 if (($attachment_common_show_images) &&
990 is_array($attachment_common_show_images_list)) {
992 foreach ($attachment_common_show_images_list as $img) {
993 $imgurl = '../src/download.php' .
995 'passed_id=' . urlencode($img['passed_id']) .
996 '&mailbox=' . urlencode($mailbox) .
997 '&passed_ent_id=' . urlencode($img['ent_id']) .
998 '&absolute_dl=true';
1000 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
1003 "<img src=\"$imgurl\">\n" .
1012 do_hook('read_body_bottom');
1013 do_hook('html_bottom');
1014 sqimap_logout($imapConnection);