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 $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];
47 elseif ($sort == 6 && $allow_server_sort != true &&
48 $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'];
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, $allow_thread_sort,
90 $allow_server_sort, $server_sort_array;
92 if ($allow_thread_sort == true ||
$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 $allow_thread_sort != true) {
107 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
108 if ($currentArrayIndex != $numMessages) {
109 $result = $currentArrayIndex +
1;
112 elseif ($allow_thread_sort != true && $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() );
209 $body = _("Your message") . "\r\n\r\n" .
210 "\t" . _("To:") . ' ' . $to . "\r\n" .
211 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
212 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
214 sprintf( _("Was displayed on %s"), $now );
218 $original_recipient = $to;
219 $original_message_id = $header->message_id
;
221 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
222 if ($original_recipient != '') {
223 $part2 .= "Original-Recipient : $original_recipient\r\n";
225 $final_recipient = $sender;
226 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
227 "Original-Message-ID : $original_message_id\r\n" .
228 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
231 $localfilename = GenerateRandomString(32, 'FILE', 7);
232 $full_localfilename = "$hashed_attachment_dir/$localfilename";
234 $fp = fopen( $full_localfilename, 'w');
235 fwrite ($fp, $part2);
238 $newAttachment = array();
239 $newAttachment['localfilename'] = $localfilename;
240 $newAttachment['type'] = "message/disposition-notification";
241 $newAttachment['session']=-1;
242 $attachments[] = $newAttachment;
243 $MDN_to = trim($recipient);
246 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
247 $body, $reply_id, True, 3, -1) );
251 function ToggleMDNflag ( $set ) {
252 global $imapConnection, $passed_id, $mailbox;
253 sqimap_mailbox_select($imapConnection, $mailbox);
256 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
257 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
261 function ClearAttachments() {
262 global $username, $attachments, $attachment_dir;
264 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
266 $rem_attachments = array();
267 foreach ($attachments as $info) {
268 if ($info->session
== -1) {
269 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
270 if (file_exists($attached_file)) {
271 unlink($attached_file);
274 $rem_attachments[] = $info;
277 $attachments = rem_attachments
;
280 function formatRecipientString($recipients, $item ) {
281 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
282 $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
287 if (isset ($recipients[0]) && trim($recipients[0])) {
293 $show = "&show_more=1&show_more_cc=$show_more_cc&".
294 "show_more_bcc=$show_more_bcc";
295 $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
296 "show_more_bcc=$show_more_bcc";
299 $show = "&show_more=$show_more&show_more_cc=1&".
300 "show_more_bcc=$show_more_bcc";
301 $show_n = "&show_more=$show_more&show_more_cc=0&".
302 "show_more_bcc=$show_more_bcc";
303 $show_more = $show_more_cc;
306 $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
307 "&show_more_bcc=1";
308 $show_n = "&show_more=$show_more&show_more_cc=".
309 "$show_more_cc&show_more_bcc=0";
310 $show_more = $show_more_bcc;
316 while ($i < count($ary)) {
317 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
318 $url_string .= $ary[$i];
320 $string = "$string<BR>$ary[$i]";
322 $string = "$ary[$i]";
326 if (count($ary) > 1) {
327 if ($show_more == false) {
329 /* From a search... */
330 $string .= ' (<A HREF="' . $base_uri .
331 "src/read_body.php?mailbox=$urlMailbox&".
332 "passed_id=$passed_id&";
333 if (isset($where) && isset($what)) {
334 $string .= 'what=' . urlencode($what).
335 "&where=".urlencode($where).
336 "$show\">$echo_more</A>)";
338 $string .= "sort=$sort&startMessage=".
339 "$startMessage"."$show\">$echo_more</A>)";
343 } else if ($i == 1) {
344 /* From a search... */
345 $string .= ' (<A HREF="' . $base_uri .
346 "src/read_body.php?mailbox=$urlMailbox&".
347 "passed_id=$passed_id&";
348 if (isset($where) && isset($what)) {
349 $string .= 'what=' . urlencode($what).
350 "&where=".urlencode($where).
351 "$show_n\">$echo_less</A>)";
353 $string .= "sort=$sort&startMessage=$startMessage".
354 "$show_n\">$echo_less</A>)";
363 $url_string = urlencode($url_string);
365 $result['str'] = $string;
366 $result['url_str'] = $url_string;
373 * Main of read_boby.php --------------------------------------------------
382 if (isset($mailbox)){
383 $mailbox = urldecode( $mailbox );
385 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
387 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
392 * The following code sets necesarry stuff for the MDN thing
394 if($default_use_mdn &&
395 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
396 $default_use_mdn))) {
398 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
399 $flags = sqimap_get_flags ($imapConnection, $passed_id);
400 $FirstTimeSee = !(in_array( 'Seen', $flags ));
403 displayPageHeader($color, $mailbox);
407 * The following code shows the header of the message and then exit
409 if (isset($view_hdr)) {
410 $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
414 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
415 ' ALIGN="CENTER">' . "\n" .
416 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
417 _("Viewing Full Header") . '</B> - '.
418 '<a href="' . $base_uri . 'src/read_body.php?mailbox='.
420 if (isset($where) && isset($what)) {
421 // Got here from a search
422 echo "&passed_id=$passed_id&where=".urlencode($where).
423 "&what=".urlencode($what).'">';
425 echo "&passed_id=$passed_id&startMessage=$startMessage".
426 "&show_more=$show_more\">";
428 echo _("View message") . "</a></b></td></tr></table>\n".
429 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
434 for ($i=1; $i < count($read); $i++
) {
435 $line = htmlspecialchars($read[$i]);
436 if (eregi("^>", $line)) {
438 $first[$i] = ' ';
440 } else if (eregi("^[ |\t]", $line)) {
443 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
444 $first[$i] = $regs[1] . ':';
445 $second[$i] = $regs[2];
448 $second[$i] = trim($line);
452 for ($i=0; $i < count($second); $i = $j) {
453 if (isset($first[$i])) {
456 if (isset($second[$i])) {
457 $s = nl2br($second[$i]);
460 while (($first[$j] == '') && ($j < count($first))) {
461 $s .= ' ' . nl2br($second[$j]);
466 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
469 echo "</td></tr></table>\n" .
471 sqimap_logout($imapConnection);
476 $currentArrayIndex = $passed_id;
478 $currentArrayIndex = -1;
481 for ($i = 0; $i < count($msgs); $i++
) {
482 if ($msgs[$i]['ID'] == $passed_id) {
483 $msgs[$i]['FLAG_SEEN'] = true;
488 * $message contains all information about the message
489 * including header and body
491 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
493 /** translate the subject and mailbox into url-able text **/
494 $url_subj = urlencode(trim($message->header
->subject
));
495 $urlMailbox = urlencode($mailbox);
497 if (isset($message->header
->replyto
)) {
498 $url_replyto = urlencode($message->header
->replyto
);
501 $url_replytoall = $url_replyto;
504 * If we are replying to all, then find all other addresses and
505 * add them to the list. Remove duplicates.
506 * This is somewhat messy, so I'll explain:
507 * 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
509 $url_replytoall_extra_addrs = array_merge(
510 array($message->header
->from
),
511 $message->header
->to
,
516 * 2) Make one big string out of them
518 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
521 * 3) Parse that into an array of addresses
523 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
526 * 4) Make them unique -- weed out duplicates
527 * (Coded for PHP 4.0.0)
529 $url_replytoall_extra_addrs =
530 array_keys(array_flip($url_replytoall_extra_addrs));
533 * 5) Remove the addresses we'll be sending the message 'to'
535 $url_replytoall_avoid_addrs = '';
536 if (isset($message->header
->replyto
)) {
537 $url_replytoall_avoid_addrs = $message->header
->replyto
;
540 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
541 foreach ($url_replytoall_avoid_addrs as $addr) {
542 RemoveAddress($url_replytoall_extra_addrs, $addr);
546 * 6) Remove our identities from the CC list (they still can be in the
547 * TO list) only if $include_self_reply_all is turned off
549 if (!$include_self_reply_all) {
550 RemoveAddress($url_replytoall_extra_addrs,
551 getPref($data_dir, $username, 'email_address'));
552 $idents = getPref($data_dir, $username, 'identities');
553 if ($idents != '' && $idents > 1) {
554 for ($i = 1; $i < $idents; $i ++
) {
555 $cur_email_address = getPref($data_dir, $username,
556 'email_address' . $i);
557 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
563 * 7) Smoosh back into one nice line
565 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
570 $url_replytoallcc = urlencode($url_replytoallcc);
572 $dateString = getLongDateString($message->header
->date
);
575 * What do we reply to -- text only, if possible
577 $ent_num = findDisplayEntity($message);
579 /** TEXT STRINGS DEFINITIONS **/
580 $echo_more = _("more");
581 $echo_less = _("less");
583 if (!isset($show_more_cc)) {
584 $show_more_cc = FALSE;
587 if (!isset($show_more_bcc)) {
588 $show_more_bcc = FALSE;
591 /** FORMAT THE TO STRING **/
592 $to = formatRecipientString($message->header
->to
, "to");
593 $to_string = $to['str'];
594 $url_to_string = $to['url_str'];
597 /** FORMAT THE CC STRING **/
599 $cc = formatRecipientString($message->header
->cc
, "cc");
600 $cc_string = $cc['str'];
601 $url_cc_string = $cc['url_str'];
603 /** FORMAT THE BCC STRING **/
605 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
606 $bcc_string = $bcc['str'];
607 $url_bcc_string = $bcc['url_str'];
609 if ($default_use_priority) {
610 $priority_level = substr($message->header
->priority
,0,1);
612 switch($priority_level) {
613 /* check for a higher then normal priority. */
616 $priority_string = _("High");
619 /* check for a lower then normal priority. */
622 $priority_string = _("Low");
625 /* check for a normal priority. */
628 $priority_level = '3';
629 $priority_string = _("Normal");
635 /** make sure everything will display in HTML format **/
636 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
637 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
639 $idents = getPref($data_dir, $username, 'identities');
640 if (!empty($idents) && $idents > 1) {
641 for ($i = 1; $i < $idents; $i++
) {
642 $enc_from_name = '"'.
643 encodeHeader(getPref($data_dir,
646 '" <' . getPref($data_dir, $username,
647 'email_address' . $i) . '>';
648 if (htmlspecialchars($enc_from_name) == $from_name) {
655 do_hook('read_body_top');
657 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
658 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
659 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
661 '<TD ALIGN="LEFT" WIDTH="33%">' .
663 '<A HREF="' . $base_uri . 'src/';
665 if ($where && $what) {
669 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
671 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
673 echo _("Message List") .
674 '</A> | ' .
675 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
676 if ($where && $what) {
677 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
679 echo "sort=$sort&startMessage=$startMessage\">";
681 echo _("Delete") . '</A> ';
682 if (($mailbox == $draft_folder) && ($save_as_draft)) {
683 echo '| <A HREF="' . $base_uri .
684 "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" . '"';
685 if ($compose_new_win == '1') {
686 echo ' TARGET="compose_window" onClick="comp_in_new()"';
689 _("Resume Draft") . '</a>';
691 if ($mailbox == $sent_folder) {
692 echo '| <A HREF="' . $base_uri .
693 "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" . '"';
694 if ($compose_new_win == '1') {
695 echo ' TARGET="compose_window" onClick="comp_in_new()"';
698 _("Edit Message as New") . '</a>';
701 echo ' ' .
704 '<TD WIDTH="33%" ALIGN="CENTER">' .
707 if ( !($where && $what) ) {
708 if ($currentArrayIndex == -1) {
709 echo 'Previous | Next';
711 $prev = findPreviousMessage();
712 $next = findNextMessage();
715 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
717 echo _("Previous") . ' | ';
721 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
729 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
731 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
732 ($default_use_priority?
"mailprio=$priority_level&":'')
733 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
734 if ($compose_new_win == '1') {
735 echo 'TARGET="compose_window" onClick="comp_in_new()"';
739 '</A> | ' .
740 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
741 ($default_use_priority?
"mailprio=$priority_level&":'').
742 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
743 if ($compose_new_win == '1') {
744 echo 'TARGET="compose_window" onClick="comp_in_new()"';
748 '</A> | ' .
749 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
750 ($default_use_priority?
"mailprio=$priority_level&":'').
751 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
752 if ($compose_new_win == '1') {
753 echo 'TARGET="compose_window" onClick="comp_in_new()"';
763 '<TR><TD WIDTH="100%">' .
764 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
768 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
770 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
771 "<B>$subject</B> \n" .
773 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
774 '" ALIGN=right VALIGN=top NOWRAP><small>'.
775 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
777 /* From a search... */
778 if ($where && $what) {
779 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
780 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
782 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
783 _("View Full Header") . "</A>\n";
786 /* Output the printer friendly link if we are in subtle mode. */
787 if ($pf_subtle_link) {
788 echo printer_friendly_link(true);
791 do_hook("read_body_header_right");
792 echo '</small></TD>' .
797 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
799 '</TD><TD BGCOLOR="' . $color[0] . '">' .
800 "<B>$from_name</B> \n" .
805 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
807 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
808 "<B>$dateString</B> \n" .
814 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
816 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
817 "<B>$to_string</B> \n" .
821 if (isset($cc_string) && $cc_string <> '') {
823 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
825 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
826 "<B>$cc_string</B> " .
832 if (isset($bcc_string) && $bcc_string <> '') {
834 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
836 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
837 "<B>$bcc_string</B> " .
841 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
843 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
844 _("Priority") . ': '.
845 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
846 "<B>$priority_string</B> " .
851 if ($show_xmailer_default) {
852 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
853 $response, $readmessage);
854 $mailer = substr($read[1], strpos($read[1], " "));
857 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
859 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
860 "<B>$mailer</B> " .
866 /* Output the printer friendly link if we are not in subtle mode. */
867 if (!$pf_subtle_link) {
868 echo printer_friendly_link(true);
871 if ($default_use_mdn) {
872 if ($mdn_user_support) {
874 // debug gives you the capability to remove mdn-flags
875 // $MDNDebug = false;
876 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
877 $response, $readmessage);
878 $MDN_to = substr($read[1], strpos($read[1], ' '));
879 $MDN_flag_present = false;
881 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
882 $response, $readmessage);
884 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
887 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
889 if ( $MDN_flag_present && $supportMDN) {
890 $sendreceipt = 'removeMDN';
891 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
896 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
897 _("Read receipt") . ': ' .
898 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
901 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
907 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
908 _("Read receipt") . ': ' .
909 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
910 '<B>'._("send").'</B>'.
917 } // when deleted or draft flag is set don't offer to send a MDN response
918 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
920 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
921 _("Read receipt") . ': '.
922 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
923 '<B>' . _("requested") . "</B>" .
927 // if no MDNsupport don't use the annoying popup messages
928 else if ( !$FirstTimeSee ) {
929 $sendreceipt = 'send';
930 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
932 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
933 _("Read receipt") . ': ' .
934 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
935 '<B>' . _("requested") .
936 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
942 $sendreceipt = 'send';
943 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
944 if ($javascript_on) {
945 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
947 " if (window.confirm(\"" .
948 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
950 " window.location=($url); \n" .
951 ' window.reload()' . "\n" .
957 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
958 _("Read receipt") . ': ' .
959 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
960 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
961 _("Send read receipt now") . '] </a>' ." \n" .
968 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
969 } else if ( $sendreceipt == 'send' ) {
970 if ( !$MDN_flag_present) {
971 if (isset($identity) ) {
972 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
974 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
977 $final_recipient = trim($final_recipient);
978 if ($final_recipient == '' ) {
979 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
982 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
983 ToggleMDNflag( true);
986 $sendreceipt = 'removeMDN';
987 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
990 if ($MDNDebug && $supportMDN) {
992 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
993 " "._("Read receipt").": \n".
994 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
995 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
1001 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
1002 " "._("Read receipt").": \n".
1003 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
1004 ' <B>'._("send").'</B>'. "\n" .
1011 elseif ($sendreceipt == 'removeMDN' ) {
1012 ToggleMDNflag ( false );
1014 $sendreceipt = 'send';
1015 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1017 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
1018 _("Read receipt") . ': ' .
1019 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
1020 '<B>' . _("requested") .
1021 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
1030 do_hook('read_body_header');
1037 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
1038 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
1040 formatBody($imapConnection, $message, $color, $wrap_at).
1041 '</TD></TR></TABLE>' .
1042 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
1043 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
1046 /* show attached images inline -- if pref'fed so */
1047 if (($attachment_common_show_images) &&
1048 is_array($attachment_common_show_images_list)) {
1050 foreach ($attachment_common_show_images_list as $img) {
1051 $imgurl = '../src/download.php' .
1053 'passed_id=' . urlencode($img['passed_id']) .
1054 '&mailbox=' . urlencode($mailbox) .
1055 '&passed_ent_id=' . urlencode($img['ent_id']) .
1056 '&absolute_dl=true';
1058 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
1061 "<img src=\"$imgurl\">\n" .
1070 do_hook('read_body_bottom');
1071 do_hook('html_bottom');
1072 sqimap_logout($imapConnection);