6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This file is used for reading the msgs array and displaying
10 * the resulting emails in the right frame.
15 require_once('../src/validate.php');
16 require_once('../functions/imap.php');
17 require_once('../functions/mime.php');
18 require_once('../functions/date.php');
19 require_once('../functions/url_parser.php');
20 require_once('../functions/smtp.php');
23 * Given an IMAP message id number, this will look it up in the cached
24 * and sorted msgs array and return the index. Used for finding the next
25 * and previous messages.
27 * returns the index of the next valid message from the array
29 function findNextMessage() {
30 global $msort, $currentArrayIndex, $msgs, $sort;
34 if ($currentArrayIndex != 1) {
35 $result = $currentArrayIndex - 1;
38 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
39 if ($currentArrayIndex == $msgs[$key]['ID']) {
43 $result = $msgs[$key]['ID'];
51 /** Removes just one address from the list of addresses. */
52 function RemoveAddress(&$addr_list, $addr) {
54 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
55 unset($addr_list[$key_to_delete]);
60 /** returns the index of the previous message from the array. */
61 function findPreviousMessage() {
62 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
63 $mailbox, $data_dir, $username;
68 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
69 if ($currentArrayIndex != $numMessages) {
70 $result = $currentArrayIndex +
1;
73 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
74 if ($currentArrayIndex == $msgs[$key]['ID']) {
78 $result = $msgs[$key]['ID'];
88 * Displays a link to a page where the message is displayed more
91 function printer_friendly_link() {
92 global $passed_id, $mailbox, $ent_num, $color,
96 if (strlen(trim($mailbox)) < 1) {
100 $params = '?passed_ent_id=' . $ent_num .
101 '&mailbox=' . urlencode($mailbox) .
102 '&passed_id=' . $passed_id;
104 $print_text = _("View Printable Version");
106 if (!$pf_subtle_link) {
107 /* The link is large, on the bottom of the header panel. */
108 $result = '<tr bgcolor="' . $color[0] . '">' .
109 '<td class="medText" align="right" valign="top">' .
111 '</td><td class="medText" valign="top" colspan="2">'."\n";
113 /* The link is subtle, below "view full header". */
117 /* Output the link. */
118 if ($javascript_on) {
119 $result .= '<script language="javascript">' . "\n" .
121 " function printFormat() {\n" .
122 ' window.open("../src/printer_friendly_main.php' .
123 $params . '","Print","width=800,height=600");' . "\n".
127 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
129 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
130 "$params\">$print_text</A>\n";
133 if (!$pf_subtle_link) {
134 /* The link is large, on the bottom of the header panel. */
135 $result .= '</td></tr>' . "\n";
141 function ServerMDNSupport( $read ) {
145 while ($num < count($read) ) {
146 $resp .= $read[$num];
149 $read[] = split(' * ', $resp);
152 while ( !$ret && $num < count($read) ) {
153 if ( ereg('PERMANENTFLAGS', $read[$num] ) ) {
154 $ret = ( ereg('mdnsent',strtolower($read[$num]) ) ||
ereg("\\\*", $read[$num] ) );
161 function SendMDN ( $recipient , $sender) {
162 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
163 $version, $attachments, $identity, $data_dir, $passed_id;
165 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
166 $header = $message->header
;
168 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
172 $senton = getLongDateString( $header->date
);
173 $to_array = $header->to
;
175 foreach ($to_array as $line) {
179 $subject = $header->subject
;
180 $now = getLongDateString( time() );
182 $body = _("Your message") . "\r\n\r\n" .
183 "\t" . _("To:") . ' ' . $to . "\r\n" .
184 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
185 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
187 sprintf( _("Was displayed on %s"), $now );
189 $body = sprintf( _("This message sent on %s to %s with subject \"%s\" has been displayed on %s."),
190 $senton, $to, $subject, $now ) .
192 _("This is no guarantee that the message has been read or understood.") . "\r\n";
196 $original_recipient = $to;
197 $original_message_id = $header->message_id
;
199 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
200 if ($original_recipient != '') {
201 $part2 .= "Original-Recipient : $original_recipient\r\n";
203 $final_recipient = $sender;
204 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
205 "Original-Message-ID : $original_message_id\r\n" .
206 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
209 $localfilename = GenerateRandomString(32, 'FILE', 7);
210 $full_localfilename = "$hashed_attachment_dir/$localfilename";
212 $fp = fopen( $full_localfilename, 'w');
213 fwrite ($fp, $part2);
216 $newAttachment = array();
217 $newAttachment['localfilename'] = $localfilename;
218 $newAttachment['type'] = "message/disposition-notification";
220 $attachments[] = $newAttachment;
221 $MDN_to = trim($recipient);
224 return (SendMessage($MDN_to,'','',"Read: $subject", $body,$reply_id, True, 3) );
228 function ToggleMDNflag ( $set ) {
230 global $imapConnection, $passed_id, $mailbox;
239 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
240 sqimap_mailbox_select($imapConnection, $mailbox);
241 $read = sqimap_run_command ($imapConnection, $cmd, true, $response, $readmessage);
245 function ClearAttachments() {
246 global $username, $attachments, $attachment_dir;
248 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
250 foreach ($attachments as $info) {
251 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
252 if (file_exists($attached_file)) {
253 unlink($attached_file);
257 $attachments = array();
262 * Main of read_boby.php --------------------------------------------------
271 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
272 $read = sqimap_mailbox_select($imapConnection, $mailbox);
277 * The following code sets necesarry stuff for the MDN thing
279 if( $default_use_mdn &&
280 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
282 $supportMDN = ServerMDNSupport($read);
283 $flags = sqimap_get_flags ($imapConnection, $passed_id);
284 $FirstTimeSee = !(in_array( 'Seen', $flags ));
287 displayPageHeader($color, $mailbox);
291 * The following code shows the header of the message and then exit
293 if (isset($view_hdr)) {
294 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
297 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
298 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\"><CENTER><B>" . _("Viewing Full Header") . '</B> - '.
299 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
300 if (isset($where) && isset($what)) {
301 // Got here from a search
302 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
304 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
306 echo _("View message") . "</a></b></center></td></tr></table>\n" .
307 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
311 for ($i=1; $i < count($read); $i++
) {
312 $line = htmlspecialchars($read[$i]);
313 if (eregi("^>", $line)) {
315 $first[$i] = ' ';
317 } else if (eregi("^[ |\t]", $line)) {
320 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
321 $first[$i] = $regs[1] . ':';
322 $second[$i] = $regs[2];
325 $second[$i] = trim($line);
329 for ($i=0; $i < count($second); $i = $j) {
330 if (isset($first[$i])) {
333 if (isset($second[$i])) {
334 $s = nl2br($second[$i]);
337 while (($first[$j] == '') && ($j < count($first))) {
338 $s .= ' ' . nl2br($second[$j]);
342 if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
344 echo "</td></tr></table>\n" .
346 sqimap_logout($imapConnection);
351 $currentArrayIndex = $passed_id;
353 $currentArrayIndex = -1;
356 for ($i = 0; $i < count($msgs); $i++
) {
357 if ($msgs[$i]['ID'] == $passed_id) {
358 $msgs[$i]['FLAG_SEEN'] = true;
362 // $message contains all information about the message
363 // including header and body
364 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
366 /** translate the subject and mailbox into url-able text **/
367 $url_subj = urlencode(trim($message->header
->subject
));
368 $urlMailbox = urlencode($mailbox);
370 if (isset($message->header
->replyto
)) {
371 $url_replyto = urlencode($message->header
->replyto
);
374 $url_replytoall = $url_replyto;
376 // If we are replying to all, then find all other addresses and
377 // add them to the list. Remove duplicates.
378 // This is somewhat messy, so I'll explain:
379 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
380 $url_replytoall_extra_addrs = array_merge(
381 array($message->header
->from
),
382 $message->header
->to
,
386 // 2) Make one big string out of them
387 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
389 // 3) Parse that into an array of addresses
390 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
392 // 4) Make them unique -- weed out duplicates
393 // (Coded for PHP 4.0.0)
394 $url_replytoall_extra_addrs =
395 array_keys(array_flip($url_replytoall_extra_addrs));
397 // 5) Remove the addresses we'll be sending the message 'to'
398 $url_replytoall_avoid_addrs = '';
399 if (isset($message->header
->replyto
)) {
400 $url_replytoall_avoid_addrs = $message->header
->replyto
;
403 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
404 foreach ($url_replytoall_avoid_addrs as $addr) {
405 RemoveAddress($url_replytoall_extra_addrs, $addr);
408 // 6) Remove our identities from the CC list (they still can be in the
409 // TO list) only if $include_self_reply_all is turned off
410 if (!$include_self_reply_all) {
411 RemoveAddress($url_replytoall_extra_addrs,
412 getPref($data_dir, $username, 'email_address'));
413 $idents = getPref($data_dir, $username, 'identities');
414 if ($idents != '' && $idents > 1) {
415 for ($i = 1; $i < $idents; $i ++
) {
416 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
417 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
422 // 7) Smoosh back into one nice line
423 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
426 $url_replytoallcc = urlencode($url_replytoallcc);
428 $dateString = getLongDateString($message->header
->date
);
430 // What do we reply to -- text only, if possible
431 $ent_num = findDisplayEntity($message);
433 /** TEXT STRINGS DEFINITIONS **/
434 $echo_more = _("more");
435 $echo_less = _("less");
437 if (!isset($show_more_cc)) {
438 $show_more_cc = FALSE;
441 /** FORMAT THE TO STRING **/
444 $to_ary = $message->header
->to
;
445 while ($i < count($to_ary)) {
446 $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i]));
449 $to_string = "$to_string<BR>$to_ary[$i]";
451 $to_string = "$to_ary[$i]";
455 if (count($to_ary) > 1) {
456 if ($show_more == false) {
458 /* From a search... */
459 $to_string .= ' (<A HREF="' . $base_uri .
460 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
461 if (isset($where) && isset($what)) {
462 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
464 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
468 } else if ($i == 1) {
469 /* From a search... */
470 $to_string .= ' (<A HREF="' . $base_uri .
471 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
472 if (isset($where) && isset($what)) {
473 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
475 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
481 /** FORMAT THE CC STRING **/
483 if (isset ($message->header
->cc
[0]) && trim($message->header
->cc
[0])) {
485 $cc_ary = $message->header
->cc
;
486 while ($i < count(decodeHeader($cc_ary))) {
487 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
489 $cc_string = "$cc_string<BR>$cc_ary[$i]";
491 $cc_string = "$cc_ary[$i]";
495 if (count($cc_ary) > 1) {
496 if ($show_more_cc == false) {
498 /* From a search... */
499 $cc_string .= ' (<A HREF="' . $base_uri .
500 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id";
501 if (isset($where) && isset($what)) {
502 $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
504 $cc_string .= "&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
508 } else if ($i == 1) {
509 /* From a search... */
510 $cc_string .= ' (<A HREF="' . $base_uri .
511 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
512 if (isset($where) && isset($what)) {
513 $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
515 $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
522 /** FORMAT THE BCC STRING **/
524 if (isset ($message->header
->bcc
[0]) && trim($message->header
->bcc
[0])){
526 $bcc_ary = $message->header
->bcc
;
527 while ($i < count(decodeHeader($bcc_ary))) {
528 $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]);
530 $bcc_string = "$bcc_string<BR>$bcc_ary[$i]";
532 $bcc_string = "$bcc_ary[$i]";
536 if (count($bcc_ary) > 1) {
537 if ($show_more_cc == false) {
539 /* From a search... */
540 $bcc_string .= ' (<A HREF="' . $base_uri .
541 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
542 if (isset($where) && isset($what)) {
543 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
545 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
547 $i = count($bcc_ary);
549 } else if ($i == 1) {
550 /* From a search... */
551 $bcc_string .= ' (<A HREF="' . $base_uri .
552 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
553 if (isset($where) && isset($what)) {
554 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
556 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
563 if ($default_use_priority) {
564 $priority_level = substr($message->header
->priority
,0,1);
566 switch($priority_level) {
567 /* check for a higher then normal priority. */
570 $priority_string = _("High");
573 /* check for a lower then normal priority. */
576 $priority_string = _("Low");
579 /* check for a normal priority. */
582 $priority_level = '3';
583 $priority_string = _("Normal");
589 /** make sure everything will display in HTML format **/
590 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
591 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
593 do_hook('read_body_top');
595 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
596 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
597 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
599 '<TD ALIGN="LEFT" WIDTH="33%">' .
601 '<A HREF="' . $base_uri . 'src/';
603 if ($where && $what) {
607 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
609 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
611 echo _("Message List") .
612 '</A> | ' .
613 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
614 if ($where && $what) {
615 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
617 echo "sort=$sort&startMessage=$startMessage\">";
619 echo _("Delete") . '</A> ';
620 if (($mailbox == $draft_folder) && ($save_as_draft)) {
621 echo '| <A HREF="' . $base_uri .
622 "src/compose.php?mailbox=$mailbox&send_to=$to_string&send_to_cc=$cc_string&send_to_bcc=$bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num\">".
623 _("Resume Draft") . '</a>';
626 echo ' ' .
629 '<TD WIDTH="33%" ALIGN="CENTER">' .
632 if ( !($where && $what) ) {
634 if ($currentArrayIndex == -1) {
635 echo 'Previous | Next';
637 $prev = findPreviousMessage();
638 $next = findNextMessage();
641 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
643 echo _("Previous") . ' | ';
647 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
655 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
657 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
658 ($default_use_priority?
"mailprio=$priority_level&":"")
659 ."mailbox=$urlMailbox&ent_num=$ent_num\">" .
661 '</A> | ' .
662 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
663 ($default_use_priority?
"mailprio=$priority_level&":"").
664 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
666 '</A> | ' .
667 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
668 ($default_use_priority?
"mailprio=$priority_level&":"").
669 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\">" .
677 '<TR><TD CELLSPACING="0" WIDTH="100%">' .
678 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
682 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
684 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
685 "<B>$subject</B> \n" .
687 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
688 '" ALIGN=right VALIGN=top NOWRAP><small>'.
689 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
691 /* From a search... */
692 if ($where && $what) {
693 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
694 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
696 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
697 _("View Full Header") . "</A>\n";
700 /* Output the printer friendly link if we are in subtle mode. */
701 if ($pf_subtle_link) {
702 echo printer_friendly_link(true);
705 do_hook("read_body_header_right");
706 echo '</small></TD>' .
711 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
713 '</TD><TD BGCOLOR="' . $color[0] . '">' .
714 "<B>$from_name</B> \n" .
719 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
721 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
722 "<B>$dateString</B> \n" .
728 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
730 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
731 "<B>$to_string</B> \n" .
735 if (isset($cc_string)) {
737 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
739 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
740 "<B>$cc_string</B> " .
746 if (isset($bcc_string)) {
748 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
750 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
751 "<B>$bcc_string</B> " .
755 if ($default_use_priority) {
756 if (isset($priority_string)) {
758 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
759 _("Priority") . ': '.
760 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
761 "<B>$priority_string</B> " .
767 if ($show_xmailer_default) {
768 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
769 $response, $readmessage);
770 $mailer = substr($read[1], strpos($read[1], " "));
773 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
775 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
776 "<B>$mailer</B> " .
782 /* Output the printer friendly link if we are not in subtle mode. */
783 if (!$pf_subtle_link) {
784 echo printer_friendly_link(true);
787 if ($default_use_mdn) {
788 if ($mdn_user_support) {
790 // debug gives you the capability to remove mdn-flags
792 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
793 $response, $readmessage);
794 $MDN_to = substr($read[1], strpos($read[1], ' '));
795 $MDN_flag_present = false;
797 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
798 $response, $readmessage);
800 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
803 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
805 if ( $MDN_flag_present && $supportMDN) {
806 $sendreceipt = 'removeMDN';
807 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
811 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
812 _("Read receipt") . ': ' .
813 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
816 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
821 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
822 _("Read receipt") . ': ' .
823 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
824 '<B>'._("send").'</B>'.
829 } // when deleted or draft flag is set don't offer to send a MDN response
830 else if ( ereg('Draft',$read[0] ||
ereg('Deleted',$read[0])) ) {
832 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
833 _("Read receipt") . ': '.
834 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
835 '<B>' . _("requested") . "</B>" .
839 // if no MDNsupport don't use the annoying popup messages
840 else if ( !$FirstTimeSee ) {
841 $sendreceipt = 'send';
842 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
844 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
845 _("Read receipt") . ': ' .
846 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
847 '<B>' . _("requested") .
848 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
854 $sendreceipt = 'send';
855 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
856 if ($javascript_on) {
857 echo "<script language=\"javascript\"> \n" .
859 " if (window.confirm(\"" .
860 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
862 " window.location=($url); \n" .
863 ' window.reload()' . "\n" .
869 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
870 _("Read receipt") . ': ' .
871 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
872 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
873 _("Send read receipt now") . '] </a>' ." \n" .
880 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
881 } else if ( $sendreceipt == 'send' ) {
882 if ( !$MDN_flag_present) {
883 if (isset($identity) ) {
884 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
886 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
889 $final_recipient = trim($final_recipient);
890 if ($final_recipient == '' ) {
891 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
894 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
895 ToggleMDNflag( true);
898 $sendreceipt = 'removeMDN';
899 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
902 if ($debug && $supportMDN) {
904 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
905 " "._("Read receipt").": \n".
906 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
907 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
912 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
913 " "._("Read receipt").": \n".
914 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
915 ' <B>'._("send").'</B>'. "\n" .
920 elseif ($sendreceipt == 'removeMDN' ) {
921 ToggleMDNflag ( false );
923 $sendreceipt = 'send';
924 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
926 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
927 _("Read receipt") . ': ' .
928 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
929 '<B>' . _("requested") .
930 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
939 do_hook('read_body_header');
946 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
947 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
949 formatBody($imapConnection, $message, $color, $wrap_at).
951 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
952 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
955 /* show attached images inline -- if pref'fed so */
956 if (($attachment_common_show_images) &&
957 is_array($attachment_common_show_images_list)) {
959 foreach ($attachment_common_show_images_list as $img) {
960 $imgurl = '../src/download.php' .
962 'passed_id=' . urlencode($img['passed_id']) .
963 '&mailbox=' . urlencode($mailbox) .
964 '&passed_ent_id=' . urlencode($img['ent_id']) .
967 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
970 "<img src=\"$imgurl\">\n" .
979 do_hook('read_body_bottom');
980 do_hook('html_bottom');
981 sqimap_logout($imapConnection);