f9d15ba3ed38e409e048144fc2198e4f9f450100
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 * @return the index of the next valid message from the array
29 function findNextMessage() {
30 global $msort, $currentArrayIndex, $msgs, $sort,
31 $thread_sort_messages, $allow_server_sort,
34 if ($thread_sort_messages == 1 ||
$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];
47 elseif ($sort == 6 && $allow_server_sort != 'true' &&
48 $thread_sort_messages != 1) {
49 if ($currentArrayIndex != 1) {
50 $result = $currentArrayIndex - 1;
53 elseif ($allow_server_sort != 'true' && $thread_sort_messages != 1 ) {
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'];
72 * Removes just one address from the list of addresses.
74 * @param &$addr_list a by-ref array of addresses
75 * @param $addr an address to remove
76 * @return void, since it operates on a by-ref param
78 function RemoveAddress(&$addr_list, $addr) {
80 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
81 unset($addr_list[$key_to_delete]);
86 /** returns the index of the previous message from the array. */
87 function findPreviousMessage() {
88 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
89 $mailbox, $data_dir, $username, $thread_sort_messages,
90 $allow_server_sort, $server_sort_array;
92 if ($thread_sort_messages == 1 ||
$allow_server_sort == 'true') {
93 reset($server_sort_array);
94 while(list($key, $value) = each ($server_sort_array)) {
95 if ($currentArrayIndex == $value) {
100 $result = $server_sort_array[$key -1];
105 elseif ($sort == 6 && $allow_server_sort != 'true' &&
106 $thread_sort_messages != 1) {
107 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
108 if ($currentArrayIndex != $numMessages) {
109 $result = $currentArrayIndex +
1;
112 elseif ($thread_sort_messages != 1 && $allow_server_sort != 'true') {
113 if (!is_array($msort)) {
116 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
117 if ($currentArrayIndex == $msgs[$key]['ID']) {
121 $result = $msgs[$key]['ID'];
131 * Displays a link to a page where the message is displayed more
132 * "printer friendly".
134 function printer_friendly_link() {
135 global $passed_id, $mailbox, $ent_num, $color,
139 if (strlen(trim($mailbox)) < 1) {
143 $params = '?passed_ent_id=' . $ent_num .
144 '&mailbox=' . urlencode($mailbox) .
145 '&passed_id=' . $passed_id;
147 $print_text = _("View Printable Version");
149 if (!$pf_subtle_link) {
150 /* The link is large, on the bottom of the header panel. */
151 $result = '<tr bgcolor="' . $color[0] . '">' .
152 '<td class="medText" align="right" valign="top">' .
154 '</td><td class="medText" valign="top" colspan="2">'."\n";
156 /* The link is subtle, below "view full header". */
160 /* Output the link. */
161 if ($javascript_on) {
162 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
164 " function printFormat() {\n" .
165 ' window.open("../src/printer_friendly_main.php' .
166 $params . '","Print","width=800,height=600");' . "\n".
170 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
172 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
173 "$params\">$print_text</A>\n";
176 if (!$pf_subtle_link) {
177 /* The link is large, on the bottom of the header panel. */
178 $result .= '</td></tr>' . "\n";
184 function ServerMDNSupport( $read ) {
185 /* escaping $ doesn't work -> \x36 */
186 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
190 function SendMDN ( $recipient , $sender) {
191 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
192 $version, $attachments, $identity, $data_dir, $passed_id;
194 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
195 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
199 $senton = getLongDateString( $header->date
);
200 $to_array = $header->to
;
202 foreach ($to_array as $line) {
206 $subject = $header->subject
;
207 $now = getLongDateString( time() );
211 $body = _("Your message") . "\r\n\r\n" .
212 "\t" . _("To:") . ' ' . $to . "\r\n" .
213 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
214 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
216 sprintf( _("Was displayed on %s"), $now );
220 $original_recipient = $to;
221 $original_message_id = $header->message_id
;
223 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
224 if ($original_recipient != '') {
225 $part2 .= "Original-Recipient : $original_recipient\r\n";
227 $final_recipient = $sender;
228 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
229 "Original-Message-ID : $original_message_id\r\n" .
230 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
233 $localfilename = GenerateRandomString(32, 'FILE', 7);
234 $full_localfilename = "$hashed_attachment_dir/$localfilename";
236 $fp = fopen( $full_localfilename, 'w');
237 fwrite ($fp, $part2);
240 $newAttachment = array();
241 $newAttachment['localfilename'] = $localfilename;
242 $newAttachment['type'] = "message/disposition-notification";
243 $newAttachment['session']=-1;
244 $attachments[] = $newAttachment;
245 $MDN_to = trim($recipient);
248 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
249 $body, $reply_id, True, 3, -1) );
253 function ToggleMDNflag ( $set ) {
254 global $imapConnection, $passed_id, $mailbox;
255 sqimap_mailbox_select($imapConnection, $mailbox);
258 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
259 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
263 function ClearAttachments() {
264 global $username, $attachments, $attachment_dir;
266 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
268 $rem_attachments = array();
269 foreach ($attachments as $info) {
270 if ($info->session
== -1) {
271 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
272 if (file_exists($attached_file)) {
273 unlink($attached_file);
276 $rem_attachments[] = $info;
279 $attachments = rem_attachments
;
282 function formatRecipientString($recipients, $item ) {
283 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
284 $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
289 if (isset ($recipients[0]) && trim($recipients[0])) {
295 $show = "&show_more=1&show_more_cc=$show_more_cc&".
296 "show_more_bcc=$show_more_bcc";
297 $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
298 "show_more_bcc=$show_more_bcc";
301 $show = "&show_more=$show_more&show_more_cc=1&".
302 "show_more_bcc=$show_more_bcc";
303 $show_n = "&show_more=$show_more&show_more_cc=0&".
304 "show_more_bcc=$show_more_bcc";
305 $show_more = $show_more_cc;
308 $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
309 "&show_more_bcc=1";
310 $show_n = "&show_more=$show_more&show_more_cc=".
311 "$show_more_cc&show_more_bcc=0";
312 $show_more = $show_more_bcc;
318 while ($i < count($ary)) {
319 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
320 $url_string .= $ary[$i];
322 $string = "$string<BR>$ary[$i]";
324 $string = "$ary[$i]";
328 if (count($ary) > 1) {
329 if ($show_more == false) {
331 /* From a search... */
332 $string .= ' (<A HREF="' . $base_uri .
333 "src/read_body.php?mailbox=$urlMailbox&".
334 "passed_id=$passed_id&";
335 if (isset($where) && isset($what)) {
336 $string .= 'what=' . urlencode($what).
337 "&where=".urlencode($where).
338 "$show\">$echo_more</A>)";
340 $string .= "sort=$sort&startMessage=".
341 "$startMessage"."$show\">$echo_more</A>)";
345 } else if ($i == 1) {
346 /* From a search... */
347 $string .= ' (<A HREF="' . $base_uri .
348 "src/read_body.php?mailbox=$urlMailbox&".
349 "passed_id=$passed_id&";
350 if (isset($where) && isset($what)) {
351 $string .= 'what=' . urlencode($what).
352 "&where=".urlencode($where).
353 "$show_n\">$echo_less</A>)";
355 $string .= "sort=$sort&startMessage=$startMessage".
356 "$show_n\">$echo_less</A>)";
365 $url_string = urlencode($url_string);
367 $result['str'] = $string;
368 $result['url_str'] = $url_string;
375 * Main of read_boby.php --------------------------------------------------
384 if (isset($mailbox)){
385 $mailbox = urldecode( $mailbox );
387 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
389 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
394 * The following code sets necesarry stuff for the MDN thing
396 if($default_use_mdn &&
397 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
398 $default_use_mdn))) {
400 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
401 $flags = sqimap_get_flags ($imapConnection, $passed_id);
402 $FirstTimeSee = !(in_array( 'Seen', $flags ));
405 displayPageHeader($color, $mailbox);
409 * The following code shows the header of the message and then exit
411 if (isset($view_hdr)) {
412 $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
416 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
417 ' ALIGN="CENTER">' . "\n" .
418 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
419 _("Viewing Full Header") . '</B> - '.
420 '<a href="' . $base_uri . 'src/read_body.php?mailbox='.
422 if (isset($where) && isset($what)) {
423 // Got here from a search
424 echo "&passed_id=$passed_id&where=".urlencode($where).
425 "&what=".urlencode($what).'">';
427 echo "&passed_id=$passed_id&startMessage=$startMessage".
428 "&show_more=$show_more\">";
430 echo _("View message") . "</a></b></td></tr></table>\n".
431 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
436 for ($i=1; $i < count($read); $i++
) {
437 $line = htmlspecialchars($read[$i]);
438 if (eregi("^>", $line)) {
440 $first[$i] = ' ';
442 } else if (eregi("^[ |\t]", $line)) {
445 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
446 $first[$i] = $regs[1] . ':';
447 $second[$i] = $regs[2];
450 $second[$i] = trim($line);
454 for ($i=0; $i < count($second); $i = $j) {
455 if (isset($first[$i])) {
458 if (isset($second[$i])) {
459 $s = nl2br($second[$i]);
462 while (($first[$j] == '') && ($j < count($first))) {
463 $s .= ' ' . nl2br($second[$j]);
468 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
471 echo "</td></tr></table>\n" .
473 sqimap_logout($imapConnection);
478 $currentArrayIndex = $passed_id;
480 $currentArrayIndex = -1;
483 for ($i = 0; $i < count($msgs); $i++
) {
484 if ($msgs[$i]['ID'] == $passed_id) {
485 $msgs[$i]['FLAG_SEEN'] = true;
490 * $message contains all information about the message
491 * including header and body
493 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
495 /** translate the subject and mailbox into url-able text **/
496 $url_subj = urlencode(trim($message->header
->subject
));
497 $urlMailbox = urlencode($mailbox);
499 if (isset($message->header
->replyto
)) {
500 $url_replyto = urlencode($message->header
->replyto
);
503 $url_replytoall = $url_replyto;
506 * If we are replying to all, then find all other addresses and
507 * add them to the list. Remove duplicates.
508 * This is somewhat messy, so I'll explain:
509 * 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
511 $url_replytoall_extra_addrs = array_merge(
512 array($message->header
->from
),
513 $message->header
->to
,
518 * 2) Make one big string out of them
520 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
523 * 3) Parse that into an array of addresses
525 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
528 * 4) Make them unique -- weed out duplicates
529 * (Coded for PHP 4.0.0)
531 $url_replytoall_extra_addrs =
532 array_keys(array_flip($url_replytoall_extra_addrs));
535 * 5) Remove the addresses we'll be sending the message 'to'
537 $url_replytoall_avoid_addrs = '';
538 if (isset($message->header
->replyto
)) {
539 $url_replytoall_avoid_addrs = $message->header
->replyto
;
542 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
543 foreach ($url_replytoall_avoid_addrs as $addr) {
544 RemoveAddress($url_replytoall_extra_addrs, $addr);
548 * 6) Remove our identities from the CC list (they still can be in the
549 * TO list) only if $include_self_reply_all is turned off
551 if (!$include_self_reply_all) {
552 RemoveAddress($url_replytoall_extra_addrs,
553 getPref($data_dir, $username, 'email_address'));
554 $idents = getPref($data_dir, $username, 'identities');
555 if ($idents != '' && $idents > 1) {
556 for ($i = 1; $i < $idents; $i ++
) {
557 $cur_email_address = getPref($data_dir, $username,
558 'email_address' . $i);
559 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
565 * 7) Smoosh back into one nice line
567 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
572 $url_replytoallcc = urlencode($url_replytoallcc);
574 $dateString = getLongDateString($message->header
->date
);
577 * What do we reply to -- text only, if possible
579 $ent_num = findDisplayEntity($message);
581 /** TEXT STRINGS DEFINITIONS **/
582 $echo_more = _("more");
583 $echo_less = _("less");
585 if (!isset($show_more_cc)) {
586 $show_more_cc = FALSE;
589 if (!isset($show_more_bcc)) {
590 $show_more_bcc = FALSE;
593 /** FORMAT THE TO STRING **/
594 $to = formatRecipientString($message->header
->to
, "to");
595 $to_string = $to['str'];
596 $url_to_string = $to['url_str'];
599 /** FORMAT THE CC STRING **/
601 $cc = formatRecipientString($message->header
->cc
, "cc");
602 $cc_string = $cc['str'];
603 $url_cc_string = $cc['url_str'];
605 /** FORMAT THE BCC STRING **/
607 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
608 $bcc_string = $bcc['str'];
609 $url_bcc_string = $bcc['url_str'];
611 if ($default_use_priority) {
612 $priority_level = substr($message->header
->priority
,0,1);
614 switch($priority_level) {
615 /* check for a higher then normal priority. */
618 $priority_string = _("High");
621 /* check for a lower then normal priority. */
624 $priority_string = _("Low");
627 /* check for a normal priority. */
630 $priority_level = '3';
631 $priority_string = _("Normal");
637 /** make sure everything will display in HTML format **/
638 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
639 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
641 $idents = getPref($data_dir, $username, 'identities');
642 if (!empty($idents) && $idents > 1) {
643 for ($i = 1; $i < $idents; $i++
) {
644 $enc_from_name = '"'.
645 encodeHeader(getPref($data_dir,
648 '" <' . getPref($data_dir, $username,
649 'email_address' . $i) . '>';
650 if (htmlspecialchars($enc_from_name) == $from_name) {
657 do_hook('read_body_top');
659 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
660 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
661 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
663 '<TD ALIGN="LEFT" WIDTH="33%">' .
665 '<A HREF="' . $base_uri . 'src/';
667 if ($where && $what) {
671 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
673 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
675 echo _("Message List") .
676 '</A> | ' .
677 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
678 if ($where && $what) {
679 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
681 echo "sort=$sort&startMessage=$startMessage\">";
683 echo _("Delete") . '</A> ';
684 if (($mailbox == $draft_folder) && ($save_as_draft)) {
685 echo '| <A HREF="' . $base_uri .
686 "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" . '"';
687 if ($compose_new_win == '1') {
688 echo ' TARGET="compose_window" onClick="comp_in_new()"';
691 _("Resume Draft") . '</a>';
693 if ($mailbox == $sent_folder) {
694 echo '| <A HREF="' . $base_uri .
695 "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" . '"';
696 if ($compose_new_win == '1') {
697 echo ' TARGET="compose_window" onClick="comp_in_new()"';
700 _("Edit Message as New") . '</a>';
703 echo ' ' .
706 '<TD WIDTH="33%" ALIGN="CENTER">' .
709 if ( !($where && $what) ) {
710 if ($currentArrayIndex == -1) {
711 echo 'Previous | Next';
713 $prev = findPreviousMessage();
714 $next = findNextMessage();
717 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
719 echo _("Previous") . ' | ';
723 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
731 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
733 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
734 ($default_use_priority?
"mailprio=$priority_level&":'')
735 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
736 if ($compose_new_win == '1') {
737 echo 'TARGET="compose_window" onClick="comp_in_new()"';
741 '</A> | ' .
742 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
743 ($default_use_priority?
"mailprio=$priority_level&":'').
744 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
745 if ($compose_new_win == '1') {
746 echo 'TARGET="compose_window" onClick="comp_in_new()"';
750 '</A> | ' .
751 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
752 ($default_use_priority?
"mailprio=$priority_level&":'').
753 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
754 if ($compose_new_win == '1') {
755 echo 'TARGET="compose_window" onClick="comp_in_new()"';
765 '<TR><TD WIDTH="100%">' .
766 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
770 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
772 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
773 "<B>$subject</B> \n" .
775 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
776 '" ALIGN=right VALIGN=top NOWRAP><small>'.
777 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
779 /* From a search... */
780 if ($where && $what) {
781 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
782 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
784 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
785 _("View Full Header") . "</A>\n";
788 /* Output the printer friendly link if we are in subtle mode. */
789 if ($pf_subtle_link) {
790 echo printer_friendly_link(true);
793 do_hook("read_body_header_right");
794 echo '</small></TD>' .
799 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
801 '</TD><TD BGCOLOR="' . $color[0] . '">' .
802 "<B>$from_name</B> \n" .
807 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
809 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
810 "<B>$dateString</B> \n" .
816 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
818 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
819 "<B>$to_string</B> \n" .
823 if (isset($cc_string) && $cc_string <> '') {
825 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
827 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
828 "<B>$cc_string</B> " .
834 if (isset($bcc_string) && $bcc_string <> '') {
836 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
838 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
839 "<B>$bcc_string</B> " .
843 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
845 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
846 _("Priority") . ': '.
847 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
848 "<B>$priority_string</B> " .
853 if ($show_xmailer_default) {
854 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
855 $response, $readmessage);
856 $mailer = substr($read[1], strpos($read[1], " "));
859 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
861 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
862 "<B>$mailer</B> " .
868 /* Output the printer friendly link if we are not in subtle mode. */
869 if (!$pf_subtle_link) {
870 echo printer_friendly_link(true);
873 if ($default_use_mdn) {
874 if ($mdn_user_support) {
876 // debug gives you the capability to remove mdn-flags
877 // $MDNDebug = false;
878 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
879 $response, $readmessage);
880 $MDN_to = substr($read[1], strpos($read[1], ' '));
881 $MDN_flag_present = false;
883 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
884 $response, $readmessage);
886 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
889 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
891 if ( $MDN_flag_present && $supportMDN) {
892 $sendreceipt = 'removeMDN';
893 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
898 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
899 _("Read receipt") . ': ' .
900 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
903 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
909 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
910 _("Read receipt") . ': ' .
911 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
912 '<B>'._("send").'</B>'.
919 } // when deleted or draft flag is set don't offer to send a MDN response
920 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
922 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
923 _("Read receipt") . ': '.
924 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
925 '<B>' . _("requested") . "</B>" .
929 // if no MDNsupport don't use the annoying popup messages
930 else if ( !$FirstTimeSee ) {
931 $sendreceipt = 'send';
932 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
934 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
935 _("Read receipt") . ': ' .
936 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
937 '<B>' . _("requested") .
938 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
944 $sendreceipt = 'send';
945 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
946 if ($javascript_on) {
947 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
949 " if (window.confirm(\"" .
950 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
952 " window.location=($url); \n" .
953 ' window.reload()' . "\n" .
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") . "  </B><a href=$url>" . '[' .
963 _("Send read receipt now") . '] </a>' ." \n" .
970 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
971 } else if ( $sendreceipt == 'send' ) {
972 if ( !$MDN_flag_present) {
973 if (isset($identity) ) {
974 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
976 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
979 $final_recipient = trim($final_recipient);
980 if ($final_recipient == '' ) {
981 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
984 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
985 ToggleMDNflag( true);
988 $sendreceipt = 'removeMDN';
989 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
992 if ($MDNDebug && $supportMDN) {
994 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
995 " "._("Read receipt").": \n".
996 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
997 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
1003 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
1004 " "._("Read receipt").": \n".
1005 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
1006 ' <B>'._("send").'</B>'. "\n" .
1013 elseif ($sendreceipt == 'removeMDN' ) {
1014 ToggleMDNflag ( false );
1016 $sendreceipt = 'send';
1017 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1019 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
1020 _("Read receipt") . ': ' .
1021 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
1022 '<B>' . _("requested") .
1023 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
1032 do_hook('read_body_header');
1039 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
1040 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
1042 formatBody($imapConnection, $message, $color, $wrap_at).
1043 '</TD></TR></TABLE>' .
1044 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
1045 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
1048 /* show attached images inline -- if pref'fed so */
1049 if (($attachment_common_show_images) &&
1050 is_array($attachment_common_show_images_list)) {
1052 foreach ($attachment_common_show_images_list as $img) {
1053 $imgurl = '../src/download.php' .
1055 'passed_id=' . urlencode($img['passed_id']) .
1056 '&mailbox=' . urlencode($mailbox) .
1057 '&passed_ent_id=' . urlencode($img['ent_id']) .
1058 '&absolute_dl=true';
1060 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
1063 "<img src=\"$imgurl\">\n" .
1072 do_hook('read_body_bottom');
1073 do_hook('html_bottom');
1074 sqimap_logout($imapConnection);