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,
33 if (!is_array($server_sort_array)) {
34 $thread_sort_messages = 0;
35 $allow_server_sort = FALSE;
38 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
39 reset($server_sort_array);
40 while(list($key, $value) = each ($server_sort_array)) {
41 if ($currentArrayIndex == $value) {
42 if ($key == (count($server_sort_array) - 1)) {
46 $result = $server_sort_array[$key +
1];
51 elseif ($sort == 6 && $allow_server_sort != TRUE &&
52 $thread_sort_messages != 1) {
53 if ($currentArrayIndex != 1) {
54 $result = $currentArrayIndex - 1;
57 elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) {
58 if (!is_array($msort)) {
61 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
62 if ($currentArrayIndex == $msgs[$key]['ID']) {
66 $result = $msgs[$key]['ID'];
76 * Removes just one address from the list of addresses.
78 * @param &$addr_list a by-ref array of addresses
79 * @param $addr an address to remove
80 * @return void, since it operates on a by-ref param
82 function RemoveAddress(&$addr_list, $addr) {
84 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
85 unset($addr_list[$key_to_delete]);
90 /** returns the index of the previous message from the array. */
91 function findPreviousMessage() {
92 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
93 $mailbox, $data_dir, $username, $thread_sort_messages,
94 $allow_server_sort, $server_sort_array;
96 if (!is_array($server_sort_array)) {
97 $thread_sort_messages = 0;
98 $allow_server_sort = FALSE;
100 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
101 reset($server_sort_array);
102 while(list($key, $value) = each ($server_sort_array)) {
103 if ($currentArrayIndex == $value) {
108 $result = $server_sort_array[$key -1];
113 elseif ($sort == 6 && $allow_server_sort != TRUE &&
114 $thread_sort_messages != 1) {
115 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
116 if ($currentArrayIndex != $numMessages) {
117 $result = $currentArrayIndex +
1;
120 elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
121 if (!is_array($msort)) {
124 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
125 if ($currentArrayIndex == $msgs[$key]['ID']) {
129 $result = $msgs[$key]['ID'];
139 * Displays a link to a page where the message is displayed more
140 * "printer friendly".
142 function printer_friendly_link() {
143 global $passed_id, $mailbox, $ent_num, $color,
147 if (strlen(trim($mailbox)) < 1) {
151 $params = '?passed_ent_id=' . $ent_num .
152 '&mailbox=' . urlencode($mailbox) .
153 '&passed_id=' . $passed_id;
155 $print_text = _("View Printable Version");
157 if (!$pf_subtle_link) {
158 /* The link is large, on the bottom of the header panel. */
159 $result = html_tag( 'tr', '', '', $color[0] ) .
160 html_tag( 'td', ' ', 'right', '', 'class="medText" valign="top"' ) .
161 html_tag( 'td', '', 'left', '', 'class="medText" valign="top" colspan="2"' ) . "\n";
163 /* The link is subtle, below "view full header". */
167 /* Output the link. */
168 if ($javascript_on) {
169 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
171 " function printFormat() {\n" .
172 ' window.open("../src/printer_friendly_main.php' .
173 $params . '","Print","width=800,height=600");' . "\n".
177 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
179 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
180 "$params\">$print_text</a>\n";
183 if (!$pf_subtle_link) {
184 /* The link is large, on the bottom of the header panel. */
185 $result .= '</td></tr>' . "\n";
191 function ServerMDNSupport( $read ) {
192 /* escaping $ doesn't work -> \x36 */
193 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
197 function SendMDN ( $recipient , $sender) {
198 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
199 $version, $attachments, $identity, $data_dir, $passed_id;
201 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
202 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
206 $senton = getLongDateString( $header->date
);
207 $to_array = $header->to
;
209 foreach ($to_array as $line) {
213 $subject = $header->subject
;
214 $now = getLongDateString( time() );
218 $body = _("Your message") . "\r\n\r\n" .
219 "\t" . _("To:") . ' ' . $to . "\r\n" .
220 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
221 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
223 sprintf( _("Was displayed on %s"), $now );
227 $original_recipient = $to;
228 $original_message_id = $header->message_id
;
230 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
231 if ($original_recipient != '') {
232 $part2 .= "Original-Recipient : $original_recipient\r\n";
234 $final_recipient = $sender;
235 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
236 "Original-Message-ID : $original_message_id\r\n" .
237 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
240 $localfilename = GenerateRandomString(32, 'FILE', 7);
241 $full_localfilename = "$hashed_attachment_dir/$localfilename";
243 $fp = fopen( $full_localfilename, 'w');
244 fwrite ($fp, $part2);
247 $newAttachment = array();
248 $newAttachment['localfilename'] = $localfilename;
249 $newAttachment['type'] = "message/disposition-notification";
250 $newAttachment['session']=-1;
251 $attachments[] = $newAttachment;
252 $MDN_to = trim($recipient);
255 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
256 $body, $reply_id, True, 3, -1) );
260 function ToggleMDNflag ( $set ) {
261 global $imapConnection, $passed_id, $mailbox;
262 sqimap_mailbox_select($imapConnection, $mailbox);
264 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
265 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
269 function ClearAttachments() {
270 global $username, $attachments, $attachment_dir;
272 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
274 $rem_attachments = array();
275 foreach ($attachments as $info) {
276 if ($info['session'] == -1) {
277 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
278 if (file_exists($attached_file)) {
279 unlink($attached_file);
282 $rem_attachments[] = $info;
285 $attachments = $rem_attachments;
288 function formatRecipientString($recipients, $item ) {
289 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
290 $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
295 if (isset ($recipients[0]) && trim($recipients[0])) {
301 $show = "&show_more=1&show_more_cc=$show_more_cc&".
302 "show_more_bcc=$show_more_bcc";
303 $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
304 "show_more_bcc=$show_more_bcc";
307 $show = "&show_more=$show_more&show_more_cc=1&".
308 "show_more_bcc=$show_more_bcc";
309 $show_n = "&show_more=$show_more&show_more_cc=0&".
310 "show_more_bcc=$show_more_bcc";
311 $show_more = $show_more_cc;
314 $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
315 "&show_more_bcc=1";
316 $show_n = "&show_more=$show_more&show_more_cc=".
317 "$show_more_cc&show_more_bcc=0";
318 $show_more = $show_more_bcc;
324 while ($i < count($ary)) {
325 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
326 $url_string .= $ary[$i];
328 $string = "$string<BR>$ary[$i]";
330 $string = "$ary[$i]";
334 if (count($ary) > 1) {
335 if ($show_more == false) {
337 /* From a search... */
338 $string .= ' (<a href="' . $base_uri .
339 "src/read_body.php?mailbox=$urlMailbox&".
340 "passed_id=$passed_id&";
341 if (isset($where) && isset($what)) {
342 $string .= 'what=' . urlencode($what).
343 "&where=".urlencode($where).
344 "$show\">$echo_more</a>)";
346 $string .= "sort=$sort&startMessage=".
347 "$startMessage"."$show\">$echo_more</a>)";
351 } else if ($i == 1) {
352 /* From a search... */
353 $string .= ' (<a href="' . $base_uri .
354 "src/read_body.php?mailbox=$urlMailbox&".
355 "passed_id=$passed_id&";
356 if (isset($where) && isset($what)) {
357 $string .= 'what=' . urlencode($what).
358 "&where=".urlencode($where).
359 "$show_n\">$echo_less</a>)";
361 $string .= "sort=$sort&startMessage=$startMessage".
362 "$show_n\">$echo_less</a>)";
371 $url_string = urlencode($url_string);
373 $result['str'] = $string;
374 $result['url_str'] = $url_string;
381 * Main of read_boby.php --------------------------------------------------
390 if (isset($mailbox)){
391 $mailbox = urldecode( $mailbox );
393 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
395 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
400 * The following code sets necesarry stuff for the MDN thing
402 if($default_use_mdn &&
403 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
404 $default_use_mdn))) {
406 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
407 $flags = sqimap_get_flags ($imapConnection, $passed_id);
408 $FirstTimeSee = !(in_array( 'Seen', $flags ));
411 displayPageHeader($color, $mailbox);
415 * The following code shows the header of the message and then exit
417 if (isset($view_hdr)) {
418 $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
422 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) . "\n" .
424 html_tag( 'td', '', 'center', $color[9], 'width="100%"' ) .
425 '<b>' . _("Viewing Full Header") . '</b> - '.
426 '<a href="' . $base_uri . 'src/read_body.php?mailbox='.
428 if (isset($where) && isset($what)) {
429 // Got here from a search
430 echo "&passed_id=$passed_id&where=".urlencode($where).
431 "&what=".urlencode($what).'">';
433 echo "&passed_id=$passed_id&startMessage=$startMessage".
434 "&show_more=$show_more\">";
436 echo _("View message") . "</a></b></td></tr></table>\n".
437 html_tag( 'table', '', 'center', '', 'width="99%" cellpadding="2" cellspacing="0" border="0"' ) . "\n" .
442 for ($i=1; $i < count($read); $i++
) {
443 $line = htmlspecialchars($read[$i]);
444 if (eregi("^>", $line)) {
446 $first[$i] = ' ';
448 } else if (eregi("^[ |\t]", $line)) {
451 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
452 $first[$i] = $regs[1] . ':';
453 $second[$i] = $regs[2];
456 $second[$i] = trim($line);
460 for ($i=0; $i < count($second); $i = $j) {
461 if (isset($first[$i])) {
464 if (isset($second[$i])) {
465 $s = nl2br($second[$i]);
468 while (($first[$j] == '') && ($j < count($first))) {
469 $s .= ' ' . nl2br($second[$j]);
472 if(strtolower($f) != 'message-id:') {
473 parseEmail($s); /* Find and linkify emailaddresses except msgid */
476 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
479 echo "</td></tr></table>\n" .
481 sqimap_logout($imapConnection);
486 $currentArrayIndex = $passed_id;
488 $currentArrayIndex = -1;
491 for ($i = 0; $i < count($msgs); $i++
) {
492 if ($msgs[$i]['ID'] == $passed_id) {
493 $msgs[$i]['FLAG_SEEN'] = true;
498 * $message contains all information about the message
499 * including header and body
501 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
503 /** translate the subject and mailbox into url-able text **/
504 $url_subj = urlencode(trim($message->header
->subject
));
505 $urlMailbox = urlencode($mailbox);
507 if (isset($message->header
->replyto
)) {
508 $url_replyto = urlencode($message->header
->replyto
);
511 $url_replytoall = $url_replyto;
514 * If we are replying to all, then find all other addresses and
515 * add them to the list. Remove duplicates.
516 * This is somewhat messy, so I'll explain:
517 * 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
519 $url_replytoall_extra_addrs = array_merge(
520 array($message->header
->from
),
521 $message->header
->to
,
526 * 2) Make one big string out of them
528 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
531 * 3) Parse that into an array of addresses
533 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
536 * 4) Make them unique -- weed out duplicates
537 * (Coded for PHP 4.0.0)
539 $url_replytoall_extra_addrs =
540 array_keys(array_flip($url_replytoall_extra_addrs));
543 * 5) Remove the addresses we'll be sending the message 'to'
545 $url_replytoall_avoid_addrs = '';
546 if (isset($message->header
->replyto
)) {
547 $url_replytoall_avoid_addrs = $message->header
->replyto
;
550 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
551 foreach ($url_replytoall_avoid_addrs as $addr) {
552 RemoveAddress($url_replytoall_extra_addrs, $addr);
556 * 6) Remove our identities from the CC list (they still can be in the
557 * TO list) only if $include_self_reply_all is turned off
559 if (!$include_self_reply_all) {
560 RemoveAddress($url_replytoall_extra_addrs,
561 getPref($data_dir, $username, 'email_address'));
562 $idents = getPref($data_dir, $username, 'identities');
563 if ($idents != '' && $idents > 1) {
564 for ($i = 1; $i < $idents; $i ++
) {
565 $cur_email_address = getPref($data_dir, $username,
566 'email_address' . $i);
567 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
573 * 7) Smoosh back into one nice line
575 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
580 $url_replytoallcc = urlencode($url_replytoallcc);
582 $dateString = getLongDateString($message->header
->date
);
584 /** TEXT STRINGS DEFINITIONS **/
585 $echo_more = _("more");
586 $echo_less = _("less");
588 if (!isset($show_more_cc)) {
589 $show_more_cc = FALSE;
592 if (!isset($show_more_bcc)) {
593 $show_more_bcc = FALSE;
596 /** FORMAT THE TO STRING **/
597 $to = formatRecipientString($message->header
->to
, "to");
598 $to_string = $to['str'];
599 $url_to_string = $to['url_str'];
602 /** FORMAT THE CC STRING **/
604 $cc = formatRecipientString($message->header
->cc
, "cc");
605 $cc_string = $cc['str'];
606 $url_cc_string = $cc['url_str'];
608 /** FORMAT THE BCC STRING **/
610 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
611 $bcc_string = $bcc['str'];
612 $url_bcc_string = $bcc['url_str'];
614 if ($default_use_priority) {
615 $priority_level = substr($message->header
->priority
,0,1);
617 switch($priority_level) {
618 /* check for a higher then normal priority. */
621 $priority_string = _("High");
624 /* check for a lower then normal priority. */
627 $priority_string = _("Low");
630 /* check for a normal priority. */
633 $priority_level = '3';
634 $priority_string = _("Normal");
640 /** make sure everything will display in HTML format **/
641 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
642 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
644 $idents = getPref($data_dir, $username, 'identities');
645 if (!empty($idents) && $idents > 1) {
646 for ($i = 1; $i < $idents; $i++
) {
647 $enc_from_name = '"'.
648 encodeHeader(getPref($data_dir,
651 '" <' . getPref($data_dir, $username,
652 'email_address' . $i) . '>';
653 if (htmlspecialchars($enc_from_name) == $from_name) {
660 do_hook('read_body_top');
662 * What do we reply to -- text only, if possible
669 if ($message->header->type0 == 'multipart' && $message->header->type1 == 'digest') {
670 listEntities($message);
671 for ($i = 0; $i < count($message->entities); $i++) {
673 $msg = $message->entities[$i];
674 $body .= $msg->header->type0 .'/'.$msg->header->type1 .'<BR>';
676 $msg->header->type0 = 'message';
677 $msg->header->type1 = 'rfc822';
678 $ent_ar = findDisplayEntity($msg, false);
679 for ($i = 0; $i < count($ent_ar); $i++) {
680 $body .= formatBody($imapConnection, $msg, $color, $wrap_at, $ent_ar[$i]);
686 $ent_ar = findDisplayEntity($message, false);
688 for ($i = 0; $i < count($ent_ar); $i++
) {
689 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i]);
695 /* first step in displaying multiple entities */
696 $ent_ar = findDisplayEntity($message,true);
698 $ent_num = $ent_ar[0];
699 for ($i = 1 ; $i < count($ent_ar); $i++
) {
700 $ent_num .= '_'.$ent_ar[$i];
703 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="0" cellspacing="0" border="0"' ) . "\n" .
705 html_tag( 'td', '', 'left', $color[9], 'width="100%"' ) .
706 html_tag( 'table', '', '', '', 'width="100%" cellpadding="3" cellspacing="0" border="0"' ) . "\n" .
708 html_tag( 'td', '', 'left', '', 'width="33%"' ) .
710 '<a href="' . $base_uri . 'src/';
712 if ($where && $what) {
716 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
718 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
720 echo _("Message List") .
721 '</a> | ' .
722 '<a href="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
723 if ($where && $what) {
724 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
726 echo "sort=$sort&startMessage=$startMessage\">";
728 echo _("Delete") . '</a> ';
729 if (($mailbox == $draft_folder) && ($save_as_draft)) {
730 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
731 "identity=$identity&send_to=$url_to_string&".
732 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
733 "subject=$url_subj&mailprio=$priority_level&".
734 "draft_id=$passed_id&ent_num=$ent_num";
736 if ($compose_new_win == '1') {
737 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
739 echo '| <a href="' . $comp_uri .'"';
742 _("Resume Draft") . '</a>';
744 if ($mailbox == $sent_folder) {
745 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
746 "identity=$identity&send_to=$url_to_string&".
747 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
748 "subject=$url_subj&mailprio=$priority_level&".
749 "ent_num=$ent_num&passed_id=$passed_id&edit_as_new=1";
751 if ($compose_new_win == '1') {
752 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
754 echo '| <a href="' . $comp_uri .'"';
757 _("Edit Message as New") . '</a>';
760 echo ' ' .
763 html_tag( 'td', '', 'center', '', 'width="33%"' ) .
766 if ( !($where && $what) ) {
767 if ($currentArrayIndex == -1) {
768 echo 'Previous | Next';
770 $prev = findPreviousMessage();
771 $next = findNextMessage();
774 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</a> | ";
776 echo _("Previous") . ' | ';
780 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</a>";
789 html_tag( 'td', '', 'right', '', 'width="33%"' ) .
791 $comp_uri = $base_uri . "src/compose.php?forward_id=$passed_id&".
792 "forward_subj=$url_subj&".
793 ($default_use_priority?
"mailprio=$priority_level&":'').
794 "mailbox=$urlMailbox&ent_num=$ent_num";
796 if ($compose_new_win == '1') {
797 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
799 echo '| <a href="' . $comp_uri .'"';
806 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replyto&".
807 "reply_subj=$url_subj&".
808 ($default_use_priority?
"mailprio=$priority_level&":'').
809 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
811 if ($compose_new_win == '1') {
812 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
814 echo '| <a href="' . $comp_uri .'"';
821 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replytoall&".
822 "send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
823 ($default_use_priority?
"mailprio=$priority_level&":'').
824 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
826 if ($compose_new_win == '1') {
827 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
829 echo '| <a href="' . $comp_uri .'"';
841 html_tag( 'td', '', 'left', '', 'width="100%"' ) .
842 html_tag( 'table', '', '', '', 'width="100%" border="0" cellspacing="0" cellpadding="3"' ) .
843 html_tag( 'tr' ) . "\n";
846 echo html_tag( 'td', _("Subject:"), 'right', $color[0], 'width="10%" valign="top"' ) .
847 html_tag( 'td', '<b>' . $subject . '</b> ' . "\n", 'left', $color[0], 'width="80%" valign="top"' ) .
848 html_tag( 'td', '', 'right', $color[0], 'rowspan="4" width="10%" valign="top" nowrap' ) .
849 '<a href="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
851 /* From a search... */
852 if ($where && $what) {
853 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
854 "&view_hdr=1\">" . _("View Full Header") . "</a>\n";
856 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
857 _("View Full Header") . "</a>\n";
860 /* Output the printer friendly link if we are in subtle mode. */
861 if ($pf_subtle_link) {
862 echo printer_friendly_link(true);
865 do_hook("read_body_header_right");
866 echo '</small></td>' .
870 echo html_tag( 'tr', "\n" .
871 html_tag( 'td', _("From:"), 'right', $color[0], 'valign="top"' ) .
873 '<b>' . $from_name . '</b> ' . "\n" ,
876 do_hook("read_body_after_from");
878 echo html_tag( 'tr', "\n" .
879 html_tag( 'td', _("Date:"), 'right', $color[0], 'valign="top"' ) .
881 '<b>' . $dateString . '</b> ' . "\n" ,
885 echo html_tag( 'tr', "\n" .
886 html_tag( 'td', _("To:"), 'right', $color[0], 'valign="top"' ) .
888 '<b>' . $to_string . '</b> ' . "\n" ,
892 if (isset($cc_string) && $cc_string <> '') {
893 echo html_tag( 'tr', "\n" .
894 html_tag( 'td', _("Cc:"), 'right', $color[0], 'valign="top"' ) .
896 '<b>' . $cc_string . '</b> ' . "\n" ,
897 'left', $color[0], 'colspan="2" valign="top"' )
902 if (isset($bcc_string) && $bcc_string <> '') {
903 echo html_tag( 'tr', "\n" .
904 html_tag( 'td', _("Bcc:"), 'right', $color[0], 'valign="top"' ) .
906 '<b>' . $bcc_string . '</b> ' . "\n" ,
907 'left', $color[0], 'colspan="2" valign="top"' )
910 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
911 echo html_tag( 'tr', "\n" .
912 html_tag( 'td', _("Priority") . ':', 'right', $color[0], 'valign="top"' ) .
914 '<b>' . $priority_string . '</b> ' . "\n" ,
915 'left', $color[0], 'colspan="2" valign="top"' )
919 if ($show_xmailer_default) {
920 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
921 $response, $readmessage);
922 $mailer = substr($read[1], strpos($read[1], " "));
924 echo html_tag( 'tr', "\n" .
925 html_tag( 'td', _("Mailer") . ':', 'right', $color[0], 'valign="top"' ) .
927 '<b>' . $mailer . '</b> ' ,
928 'left', $color[0], 'colspan="2" valign="top"' )
933 /* Output the printer friendly link if we are not in subtle mode. */
934 if (!$pf_subtle_link) {
935 echo printer_friendly_link(true);
938 if ($default_use_mdn) {
939 if ($mdn_user_support) {
941 // debug gives you the capability to remove mdn-flags
942 // $MDNDebug = false;
943 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
944 $response, $readmessage);
945 $MDN_to = substr($read[1], strpos($read[1], ' '));
946 $MDN_flag_present = false;
948 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
949 $response, $readmessage);
950 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
953 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
955 if ( $MDN_flag_present && $supportMDN) {
956 $sendreceipt = 'removeMDN';
957 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
961 echo html_tag( 'tr', "\n" .
962 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
964 '<b>' . _("send") . '</b> <a href="' . $url . '">[' . _("Remove MDN flag") . '] </a> ' ,
965 'left', $color[9], 'colspan="2" valign="top"' )
969 echo html_tag( 'tr', "\n" .
970 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
972 '<b>' . _("send") . '</b> ' ,
973 'left', $color[9], 'colspan="2" valign="top"' )
979 } // when deleted or draft flag is set don't offer to send a MDN response
980 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
981 echo html_tag( 'tr', "\n" .
982 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
984 '<b>' . _("requested") . '</b> ' ,
985 'left', $color[9], 'colspan="2" valign="top"' )
988 // if no MDNsupport don't use the annoying popup messages
989 else if ( !$FirstTimeSee ) {
990 $sendreceipt = 'send';
991 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
992 echo html_tag( 'tr', "\n" .
993 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
995 '<b>' . _("requested") . '</b> <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
996 'left', $color[9], 'colspan="2" valign="top"' )
1001 $sendreceipt = 'send';
1002 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1003 if ($javascript_on) {
1004 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
1006 " if (window.confirm(\"" .
1007 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
1009 ' window.open('.$url.',"right");' . "\n" .
1014 echo html_tag( 'tr', "\n" .
1015 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1017 '<b>' . _("requested") . '</b>  <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
1018 'left', $color[9], 'colspan="2" valign="top"' )
1024 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
1025 } else if ( $sendreceipt == 'send' ) {
1026 if ( !$MDN_flag_present) {
1027 if (isset($identity) ) {
1028 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
1030 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
1033 $final_recipient = trim($final_recipient);
1034 if ($final_recipient == '' ) {
1035 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
1038 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
1039 ToggleMDNflag( true);
1043 $sendreceipt = 'removeMDN';
1044 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1047 if ($MDNDebug && $supportMDN) {
1048 echo html_tag( 'tr', "\n" .
1049 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1051 '<b>' . _("send") . '</b>  <a href="' . $url . '">[' . _("Remove MDN flag") . ']</a>',
1052 'left', $color[9], 'colspan="2" valign="top"' )
1056 echo html_tag( 'tr', "\n" .
1057 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1059 '<b>' . _("send") . '</b> ',
1060 'left', $color[9], 'colspan="2" valign="top"' )
1066 elseif ($sendreceipt == 'removeMDN' ) {
1067 ToggleMDNflag ( false );
1069 $sendreceipt = 'send';
1070 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1071 echo html_tag( 'tr', "\n" .
1072 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1074 '<b>' . _("requested") . '</b> <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
1075 'left', $color[9], 'colspan="2" valign="top"' )
1083 do_hook('read_body_header');
1089 echo html_tag( 'table', "\n" .
1090 html_tag( 'tr', "\n" .
1091 html_tag( 'td', '<br>' . "\n" . $body . "\n", 'left', $color[4]
1094 'center', '', 'cellspacing=0 width="97%" border="0" cellpadding="0"') .
1096 html_tag( 'table', "\n" .
1097 html_tag( 'tr', "\n" .
1098 html_tag( 'td', ' ', 'left', $color[9]
1101 'center', '', 'cellspacing=0 width="100%" border="0" cellpadding="0"');
1103 /* show attached images inline -- if pref'fed so */
1104 if (($attachment_common_show_images) &&
1105 is_array($attachment_common_show_images_list)) {
1107 foreach ($attachment_common_show_images_list as $img) {
1108 $imgurl = '../src/download.php' .
1110 'passed_id=' . urlencode($img['passed_id']) .
1111 '&mailbox=' . urlencode($mailbox) .
1112 '&passed_ent_id=' . urlencode($img['ent_id']) .
1113 '&absolute_dl=true';
1115 echo html_tag( 'table', "\n" .
1116 html_tag( 'tr', "\n" .
1117 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
1120 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
1125 do_hook('read_body_bottom');
1126 do_hook('html_bottom');
1127 sqimap_logout($imapConnection);