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');
21 require_once('../functions/html.php');
24 * Given an IMAP message id number, this will look it up in the cached
25 * and sorted msgs array and return the index. Used for finding the next
26 * and previous messages.
28 * @return the index of the next valid message from the array
30 function findNextMessage() {
31 global $msort, $currentArrayIndex, $msgs, $sort,
32 $thread_sort_messages, $allow_server_sort,
34 if (!is_array($server_sort_array)) {
35 $thread_sort_messages = 0;
36 $allow_server_sort = FALSE;
39 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
40 reset($server_sort_array);
41 while(list($key, $value) = each ($server_sort_array)) {
42 if ($currentArrayIndex == $value) {
43 if ($key == (count($server_sort_array) - 1)) {
47 $result = $server_sort_array[$key +
1];
52 elseif ($sort == 6 && $allow_server_sort != TRUE &&
53 $thread_sort_messages != 1) {
54 if ($currentArrayIndex != 1) {
55 $result = $currentArrayIndex - 1;
58 elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) {
59 if (!is_array($msort)) {
62 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
63 if ($currentArrayIndex == $msgs[$key]['ID']) {
67 $result = $msgs[$key]['ID'];
77 * Removes just one address from the list of addresses.
79 * @param &$addr_list a by-ref array of addresses
80 * @param $addr an address to remove
81 * @return void, since it operates on a by-ref param
83 function RemoveAddress(&$addr_list, $addr) {
85 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
86 unset($addr_list[$key_to_delete]);
91 /** returns the index of the previous message from the array. */
92 function findPreviousMessage() {
93 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
94 $mailbox, $data_dir, $username, $thread_sort_messages,
95 $allow_server_sort, $server_sort_array;
97 if (!is_array($server_sort_array)) {
98 $thread_sort_messages = 0;
99 $allow_server_sort = FALSE;
101 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
102 reset($server_sort_array);
103 while(list($key, $value) = each ($server_sort_array)) {
104 if ($currentArrayIndex == $value) {
109 $result = $server_sort_array[$key -1];
114 elseif ($sort == 6 && $allow_server_sort != TRUE &&
115 $thread_sort_messages != 1) {
116 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
117 if ($currentArrayIndex != $numMessages) {
118 $result = $currentArrayIndex +
1;
121 elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
122 if (!is_array($msort)) {
125 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
126 if ($currentArrayIndex == $msgs[$key]['ID']) {
130 $result = $msgs[$key]['ID'];
140 * Displays a link to a page where the message is displayed more
141 * "printer friendly".
143 function printer_friendly_link() {
144 global $passed_id, $mailbox, $ent_num, $color,
148 if (strlen(trim($mailbox)) < 1) {
152 $params = '?passed_ent_id=' . $ent_num .
153 '&mailbox=' . urlencode($mailbox) .
154 '&passed_id=' . $passed_id;
156 $print_text = _("View Printable Version");
158 if (!$pf_subtle_link) {
159 /* The link is large, on the bottom of the header panel. */
160 $result = html_tag( 'tr', '', '', $color[0] ) .
161 html_tag( 'td', ' ', 'right', '', 'class="medText" valign="top"' ) .
162 html_tag( 'td', '', 'left', '', 'class="medText" valign="top" colspan="2"' ) . "\n";
164 /* The link is subtle, below "view full header". */
168 /* Output the link. */
169 if ($javascript_on) {
170 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
172 " function printFormat() {\n" .
173 ' window.open("../src/printer_friendly_main.php' .
174 $params . '","Print","width=800,height=600");' . "\n".
178 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
180 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
181 "$params\">$print_text</a>\n";
184 if (!$pf_subtle_link) {
185 /* The link is large, on the bottom of the header panel. */
186 $result .= '</td></tr>' . "\n";
192 function ServerMDNSupport( $read ) {
193 /* escaping $ doesn't work -> \x36 */
194 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
198 function SendMDN ( $recipient , $sender) {
199 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
200 $version, $attachments, $identity, $data_dir, $passed_id;
202 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
203 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
207 $senton = getLongDateString( $header->date
);
208 $to_array = $header->to
;
210 foreach ($to_array as $line) {
214 $subject = $header->subject
;
215 $now = getLongDateString( time() );
219 $body = _("Your message") . "\r\n\r\n" .
220 "\t" . _("To:") . ' ' . $to . "\r\n" .
221 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
222 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
224 sprintf( _("Was displayed on %s"), $now );
228 $original_recipient = $to;
229 $original_message_id = $header->message_id
;
231 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
232 if ($original_recipient != '') {
233 $part2 .= "Original-Recipient : $original_recipient\r\n";
235 $final_recipient = $sender;
236 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
237 "Original-Message-ID : $original_message_id\r\n" .
238 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
241 $localfilename = GenerateRandomString(32, 'FILE', 7);
242 $full_localfilename = "$hashed_attachment_dir/$localfilename";
244 $fp = fopen( $full_localfilename, 'w');
245 fwrite ($fp, $part2);
248 $newAttachment = array();
249 $newAttachment['localfilename'] = $localfilename;
250 $newAttachment['type'] = "message/disposition-notification";
251 $newAttachment['session']=-1;
252 $attachments[] = $newAttachment;
253 $MDN_to = trim($recipient);
256 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
257 $body, $reply_id, True, 3, -1) );
261 function ToggleMDNflag ( $set ) {
262 global $imapConnection, $passed_id, $mailbox;
263 sqimap_mailbox_select($imapConnection, $mailbox);
265 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
266 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
270 function ClearAttachments() {
271 global $username, $attachments, $attachment_dir;
273 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
275 $rem_attachments = array();
276 foreach ($attachments as $info) {
277 if ($info['session'] == -1) {
278 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
279 if (file_exists($attached_file)) {
280 unlink($attached_file);
283 $rem_attachments[] = $info;
286 $attachments = $rem_attachments;
289 function formatRecipientString($recipients, $item ) {
290 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
291 $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
296 if (isset ($recipients[0]) && trim($recipients[0])) {
302 $show = "&show_more=1&show_more_cc=$show_more_cc&".
303 "show_more_bcc=$show_more_bcc";
304 $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
305 "show_more_bcc=$show_more_bcc";
308 $show = "&show_more=$show_more&show_more_cc=1&".
309 "show_more_bcc=$show_more_bcc";
310 $show_n = "&show_more=$show_more&show_more_cc=0&".
311 "show_more_bcc=$show_more_bcc";
312 $show_more = $show_more_cc;
315 $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
316 "&show_more_bcc=1";
317 $show_n = "&show_more=$show_more&show_more_cc=".
318 "$show_more_cc&show_more_bcc=0";
319 $show_more = $show_more_bcc;
325 while ($i < count($ary)) {
326 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
327 $url_string .= $ary[$i];
329 $string = "$string<BR>$ary[$i]";
331 $string = "$ary[$i]";
335 if (count($ary) > 1) {
336 if ($show_more == false) {
338 /* From a search... */
339 $string .= ' (<a href="' . $base_uri .
340 "src/read_body.php?mailbox=$urlMailbox&".
341 "passed_id=$passed_id&";
342 if (isset($where) && isset($what)) {
343 $string .= 'what=' . urlencode($what).
344 "&where=".urlencode($where).
345 "$show\">$echo_more</a>)";
347 $string .= "sort=$sort&startMessage=".
348 "$startMessage"."$show\">$echo_more</a>)";
352 } else if ($i == 1) {
353 /* From a search... */
354 $string .= ' (<a href="' . $base_uri .
355 "src/read_body.php?mailbox=$urlMailbox&".
356 "passed_id=$passed_id&";
357 if (isset($where) && isset($what)) {
358 $string .= 'what=' . urlencode($what).
359 "&where=".urlencode($where).
360 "$show_n\">$echo_less</a>)";
362 $string .= "sort=$sort&startMessage=$startMessage".
363 "$show_n\">$echo_less</a>)";
372 $url_string = urlencode($url_string);
374 $result['str'] = $string;
375 $result['url_str'] = $url_string;
382 * Main of read_boby.php --------------------------------------------------
391 if (isset($mailbox)){
392 $mailbox = urldecode( $mailbox );
394 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
396 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
401 * The following code sets necesarry stuff for the MDN thing
403 if($default_use_mdn &&
404 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
405 $default_use_mdn))) {
407 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
408 $flags = sqimap_get_flags ($imapConnection, $passed_id);
409 $FirstTimeSee = !(in_array( 'Seen', $flags ));
412 displayPageHeader($color, $mailbox);
416 * The following code shows the header of the message and then exit
418 if (isset($view_hdr)) {
419 $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
423 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) . "\n" .
425 html_tag( 'td', '', 'center', $color[9], 'width="100%"' ) .
426 '<b>' . _("Viewing Full Header") . '</b> - '.
427 '<a href="' . $base_uri . 'src/read_body.php?mailbox='.
429 if (isset($where) && isset($what)) {
430 // Got here from a search
431 echo "&passed_id=$passed_id&where=".urlencode($where).
432 "&what=".urlencode($what).'">';
434 echo "&passed_id=$passed_id&startMessage=$startMessage".
435 "&show_more=$show_more\">";
437 echo _("View message") . "</a></b></td></tr></table>\n".
438 html_tag( 'table', '', 'center', '', 'width="99%" cellpadding="2" cellspacing="0" border="0"' ) . "\n" .
443 for ($i=1; $i < count($read); $i++
) {
444 $line = htmlspecialchars($read[$i]);
445 if (eregi("^>", $line)) {
447 $first[$i] = ' ';
449 } else if (eregi("^[ |\t]", $line)) {
452 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
453 $first[$i] = $regs[1] . ':';
454 $second[$i] = $regs[2];
457 $second[$i] = trim($line);
461 for ($i=0; $i < count($second); $i = $j) {
462 if (isset($first[$i])) {
465 if (isset($second[$i])) {
466 $s = nl2br($second[$i]);
469 while (($first[$j] == '') && ($j < count($first))) {
470 $s .= ' ' . nl2br($second[$j]);
473 if(strtolower($f) != 'message-id:') {
474 parseEmail($s); /* Find and linkify emailaddresses except msgid */
477 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
480 echo "</td></tr></table>\n" .
482 sqimap_logout($imapConnection);
487 $currentArrayIndex = $passed_id;
489 $currentArrayIndex = -1;
492 for ($i = 0; $i < count($msgs); $i++
) {
493 if ($msgs[$i]['ID'] == $passed_id) {
494 $msgs[$i]['FLAG_SEEN'] = true;
499 * $message contains all information about the message
500 * including header and body
502 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
504 /** translate the subject and mailbox into url-able text **/
505 $url_subj = urlencode(trim($message->header
->subject
));
506 $urlMailbox = urlencode($mailbox);
508 if (isset($message->header
->replyto
)) {
509 $url_replyto = urlencode($message->header
->replyto
);
512 $url_replytoall = $url_replyto;
515 * If we are replying to all, then find all other addresses and
516 * add them to the list. Remove duplicates.
517 * This is somewhat messy, so I'll explain:
518 * 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
520 $url_replytoall_extra_addrs = array_merge(
521 array($message->header
->from
),
522 $message->header
->to
,
527 * 2) Make one big string out of them
529 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
532 * 3) Parse that into an array of addresses
534 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
537 * 4) Make them unique -- weed out duplicates
538 * (Coded for PHP 4.0.0)
540 $url_replytoall_extra_addrs =
541 array_keys(array_flip($url_replytoall_extra_addrs));
544 * 5) Remove the addresses we'll be sending the message 'to'
546 $url_replytoall_avoid_addrs = '';
547 if (isset($message->header
->replyto
)) {
548 $url_replytoall_avoid_addrs = $message->header
->replyto
;
551 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
552 foreach ($url_replytoall_avoid_addrs as $addr) {
553 RemoveAddress($url_replytoall_extra_addrs, $addr);
557 * 6) Remove our identities from the CC list (they still can be in the
558 * TO list) only if $include_self_reply_all is turned off
560 if (!$include_self_reply_all) {
561 RemoveAddress($url_replytoall_extra_addrs,
562 getPref($data_dir, $username, 'email_address'));
563 $idents = getPref($data_dir, $username, 'identities');
564 if ($idents != '' && $idents > 1) {
565 for ($i = 1; $i < $idents; $i ++
) {
566 $cur_email_address = getPref($data_dir, $username,
567 'email_address' . $i);
568 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
574 * 7) Smoosh back into one nice line
576 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
581 $url_replytoallcc = urlencode($url_replytoallcc);
583 $dateString = getLongDateString($message->header
->date
);
585 /** TEXT STRINGS DEFINITIONS **/
586 $echo_more = _("more");
587 $echo_less = _("less");
589 if (!isset($show_more_cc)) {
590 $show_more_cc = FALSE;
593 if (!isset($show_more_bcc)) {
594 $show_more_bcc = FALSE;
597 /** FORMAT THE TO STRING **/
598 $to = formatRecipientString($message->header
->to
, "to");
599 $to_string = $to['str'];
600 $url_to_string = $to['url_str'];
603 /** FORMAT THE CC STRING **/
605 $cc = formatRecipientString($message->header
->cc
, "cc");
606 $cc_string = $cc['str'];
607 $url_cc_string = $cc['url_str'];
609 /** FORMAT THE BCC STRING **/
611 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
612 $bcc_string = $bcc['str'];
613 $url_bcc_string = $bcc['url_str'];
615 if ($default_use_priority) {
616 $priority_level = substr($message->header
->priority
,0,1);
618 switch($priority_level) {
619 /* check for a higher then normal priority. */
622 $priority_string = _("High");
625 /* check for a lower then normal priority. */
628 $priority_string = _("Low");
631 /* check for a normal priority. */
634 $priority_level = '3';
635 $priority_string = _("Normal");
641 /** make sure everything will display in HTML format **/
642 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
643 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
645 $idents = getPref($data_dir, $username, 'identities');
646 if (!empty($idents) && $idents > 1) {
647 for ($i = 1; $i < $idents; $i++
) {
648 $enc_from_name = '"'.
649 encodeHeader(getPref($data_dir,
652 '" <' . getPref($data_dir, $username,
653 'email_address' . $i) . '>';
654 if (htmlspecialchars($enc_from_name) == $from_name) {
661 do_hook('read_body_top');
663 * What do we reply to -- text only, if possible
670 if ($message->header->type0 == 'multipart' && $message->header->type1 == 'digest') {
671 listEntities($message);
672 for ($i = 0; $i < count($message->entities); $i++) {
674 $msg = $message->entities[$i];
675 $body .= $msg->header->type0 .'/'.$msg->header->type1 .'<BR>';
677 $msg->header->type0 = 'message';
678 $msg->header->type1 = 'rfc822';
679 $ent_ar = findDisplayEntity($msg, false);
680 for ($i = 0; $i < count($ent_ar); $i++) {
681 $body .= formatBody($imapConnection, $msg, $color, $wrap_at, $ent_ar[$i]);
687 $ent_ar = findDisplayEntity($message, false);
689 for ($i = 0; $i < count($ent_ar); $i++
) {
690 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i]);
696 /* first step in displaying multiple entities */
697 $ent_ar = findDisplayEntity($message,true);
699 $ent_num = $ent_ar[0];
700 for ($i = 1 ; $i < count($ent_ar); $i++
) {
701 $ent_num .= '_'.$ent_ar[$i];
704 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="0" cellspacing="0" border="0"' ) . "\n" .
706 html_tag( 'td', '', 'left', $color[9], 'width="100%"' ) .
707 html_tag( 'table', '', '', '', 'width="100%" cellpadding="3" cellspacing="0" border="0"' ) . "\n" .
709 html_tag( 'td', '', 'left', '', 'width="33%"' ) .
711 '<a href="' . $base_uri . 'src/';
713 if ($where && $what) {
717 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
719 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
721 echo _("Message List") .
722 '</a> | ' .
723 '<a href="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
724 if ($where && $what) {
725 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
727 echo "sort=$sort&startMessage=$startMessage\">";
729 echo _("Delete") . '</a> ';
730 if (($mailbox == $draft_folder) && ($save_as_draft)) {
731 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
732 "identity=$identity&send_to=$url_to_string&".
733 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
734 "subject=$url_subj&mailprio=$priority_level&".
735 "draft_id=$passed_id&ent_num=$ent_num";
737 if ($compose_new_win == '1') {
738 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
740 echo '| <a href="' . $comp_uri .'"';
743 _("Resume Draft") . '</a>';
745 if ($mailbox == $sent_folder) {
746 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
747 "identity=$identity&send_to=$url_to_string&".
748 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
749 "subject=$url_subj&mailprio=$priority_level&".
750 "ent_num=$ent_num&passed_id=$passed_id&edit_as_new=1";
752 if ($compose_new_win == '1') {
753 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
755 echo '| <a href="' . $comp_uri .'"';
758 _("Edit Message as New") . '</a>';
761 echo ' ' .
764 html_tag( 'td', '', 'center', '', 'width="33%"' ) .
767 if ( !($where && $what) ) {
768 if ($currentArrayIndex == -1) {
769 echo 'Previous | Next';
771 $prev = findPreviousMessage();
772 $next = findNextMessage();
775 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</a> | ";
777 echo _("Previous") . ' | ';
781 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</a>";
790 html_tag( 'td', '', 'right', '', 'width="33%"' ) .
792 $comp_uri = $base_uri . "src/compose.php?forward_id=$passed_id&".
793 "forward_subj=$url_subj&".
794 ($default_use_priority?
"mailprio=$priority_level&":'').
795 "mailbox=$urlMailbox&ent_num=$ent_num";
797 if ($compose_new_win == '1') {
798 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
800 echo '| <a href="' . $comp_uri .'"';
807 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replyto&".
808 "reply_subj=$url_subj&".
809 ($default_use_priority?
"mailprio=$priority_level&":'').
810 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
812 if ($compose_new_win == '1') {
813 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
815 echo '| <a href="' . $comp_uri .'"';
822 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replytoall&".
823 "send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
824 ($default_use_priority?
"mailprio=$priority_level&":'').
825 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
827 if ($compose_new_win == '1') {
828 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
830 echo '| <a href="' . $comp_uri .'"';
842 html_tag( 'td', '', 'left', '', 'width="100%"' ) .
843 html_tag( 'table', '', '', '', 'width="100%" border="0" cellspacing="0" cellpadding="3"' ) .
844 html_tag( 'tr' ) . "\n";
847 echo html_tag( 'td', _("Subject:"), 'right', $color[0], 'width="10%" valign="top"' ) .
848 html_tag( 'td', '<b>' . $subject . '</b> ' . "\n", 'left', $color[0], 'width="80%" valign="top"' ) .
849 html_tag( 'td', '', 'right', $color[0], 'rowspan="4" width="10%" valign="top" nowrap' ) .
850 '<a href="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
852 /* From a search... */
853 if ($where && $what) {
854 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
855 "&view_hdr=1\">" . _("View Full Header") . "</a>\n";
857 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
858 _("View Full Header") . "</a>\n";
861 /* Output the printer friendly link if we are in subtle mode. */
862 if ($pf_subtle_link) {
863 echo printer_friendly_link(true);
866 do_hook("read_body_header_right");
867 echo '</small></td>' .
871 echo html_tag( 'tr', "\n" .
872 html_tag( 'td', _("From:"), 'right', $color[0], 'valign="top"' ) .
874 '<b>' . $from_name . '</b> ' . "\n" ,
877 do_hook("read_body_after_from");
879 echo html_tag( 'tr', "\n" .
880 html_tag( 'td', _("Date:"), 'right', $color[0], 'valign="top"' ) .
882 '<b>' . $dateString . '</b> ' . "\n" ,
886 echo html_tag( 'tr', "\n" .
887 html_tag( 'td', _("To:"), 'right', $color[0], 'valign="top"' ) .
889 '<b>' . $to_string . '</b> ' . "\n" ,
893 if (isset($cc_string) && $cc_string <> '') {
894 echo html_tag( 'tr', "\n" .
895 html_tag( 'td', _("Cc:"), 'right', $color[0], 'valign="top"' ) .
897 '<b>' . $cc_string . '</b> ' . "\n" ,
898 'left', $color[0], 'colspan="2" valign="top"' )
903 if (isset($bcc_string) && $bcc_string <> '') {
904 echo html_tag( 'tr', "\n" .
905 html_tag( 'td', _("Bcc:"), 'right', $color[0], 'valign="top"' ) .
907 '<b>' . $bcc_string . '</b> ' . "\n" ,
908 'left', $color[0], 'colspan="2" valign="top"' )
911 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
912 echo html_tag( 'tr', "\n" .
913 html_tag( 'td', _("Priority") . ':', 'right', $color[0], 'valign="top"' ) .
915 '<b>' . $priority_string . '</b> ' . "\n" ,
916 'left', $color[0], 'colspan="2" valign="top"' )
920 if ($show_xmailer_default) {
921 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
922 $response, $readmessage);
923 $mailer = substr($read[1], strpos($read[1], " "));
925 echo html_tag( 'tr', "\n" .
926 html_tag( 'td', _("Mailer") . ':', 'right', $color[0], 'valign="top"' ) .
928 '<b>' . $mailer . '</b> ' ,
929 'left', $color[0], 'colspan="2" valign="top"' )
934 /* Output the printer friendly link if we are not in subtle mode. */
935 if (!$pf_subtle_link) {
936 echo printer_friendly_link(true);
939 if ($default_use_mdn) {
940 if ($mdn_user_support) {
942 // debug gives you the capability to remove mdn-flags
943 // $MDNDebug = false;
944 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
945 $response, $readmessage);
946 $MDN_to = substr($read[1], strpos($read[1], ' '));
947 $MDN_flag_present = false;
949 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
950 $response, $readmessage);
951 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
954 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
956 if ( $MDN_flag_present && $supportMDN) {
957 $sendreceipt = 'removeMDN';
958 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
962 echo html_tag( 'tr', "\n" .
963 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
965 '<b>' . _("send") . '</b> <a href="' . $url . '">[' . _("Remove MDN flag") . '] </a> ' ,
966 'left', $color[9], 'colspan="2" valign="top"' )
970 echo html_tag( 'tr', "\n" .
971 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
973 '<b>' . _("send") . '</b> ' ,
974 'left', $color[9], 'colspan="2" valign="top"' )
980 } // when deleted or draft flag is set don't offer to send a MDN response
981 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
982 echo html_tag( 'tr', "\n" .
983 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
985 '<b>' . _("requested") . '</b> ' ,
986 'left', $color[9], 'colspan="2" valign="top"' )
989 // if no MDNsupport don't use the annoying popup messages
990 else if ( !$FirstTimeSee ) {
991 $sendreceipt = 'send';
992 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
993 echo html_tag( 'tr', "\n" .
994 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
996 '<b>' . _("requested") . '</b> <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
997 'left', $color[9], 'colspan="2" valign="top"' )
1002 $sendreceipt = 'send';
1003 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1004 if ($javascript_on) {
1005 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
1007 " if (window.confirm(\"" .
1008 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
1010 ' window.open('.$url.',"right");' . "\n" .
1015 echo html_tag( 'tr', "\n" .
1016 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1018 '<b>' . _("requested") . '</b>  <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
1019 'left', $color[9], 'colspan="2" valign="top"' )
1025 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
1026 } else if ( $sendreceipt == 'send' ) {
1027 if ( !$MDN_flag_present) {
1028 if (isset($identity) ) {
1029 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
1031 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
1034 $final_recipient = trim($final_recipient);
1035 if ($final_recipient == '' ) {
1036 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
1039 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
1040 ToggleMDNflag( true);
1044 $sendreceipt = 'removeMDN';
1045 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1048 if ($MDNDebug && $supportMDN) {
1049 echo html_tag( 'tr', "\n" .
1050 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1052 '<b>' . _("send") . '</b>  <a href="' . $url . '">[' . _("Remove MDN flag") . ']</a>',
1053 'left', $color[9], 'colspan="2" valign="top"' )
1057 echo html_tag( 'tr', "\n" .
1058 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1060 '<b>' . _("send") . '</b> ',
1061 'left', $color[9], 'colspan="2" valign="top"' )
1067 elseif ($sendreceipt == 'removeMDN' ) {
1068 ToggleMDNflag ( false );
1070 $sendreceipt = 'send';
1071 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1072 echo html_tag( 'tr', "\n" .
1073 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1075 '<b>' . _("requested") . '</b> <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
1076 'left', $color[9], 'colspan="2" valign="top"' )
1084 do_hook('read_body_header');
1090 echo html_tag( 'table', "\n" .
1091 html_tag( 'tr', "\n" .
1092 html_tag( 'td', '<br>' . "\n" . $body . "\n", 'left', $color[4]
1095 'center', '', 'cellspacing=0 width="97%" border="0" cellpadding="0"') .
1097 html_tag( 'table', "\n" .
1098 html_tag( 'tr', "\n" .
1099 html_tag( 'td', ' ', 'left', $color[9]
1102 'center', '', 'cellspacing=0 width="100%" border="0" cellpadding="0"');
1104 /* show attached images inline -- if pref'fed so */
1105 if (($attachment_common_show_images) &&
1106 is_array($attachment_common_show_images_list)) {
1108 foreach ($attachment_common_show_images_list as $img) {
1109 $imgurl = '../src/download.php' .
1111 'passed_id=' . urlencode($img['passed_id']) .
1112 '&mailbox=' . urlencode($mailbox) .
1113 '&passed_ent_id=' . urlencode($img['ent_id']) .
1114 '&absolute_dl=true';
1116 echo html_tag( 'table', "\n" .
1117 html_tag( 'tr', "\n" .
1118 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
1121 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
1126 do_hook('read_body_bottom');
1127 do_hook('html_bottom');
1128 sqimap_logout($imapConnection);