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 $ret = preg_match( '/.*PERMANENTFLAGS.*(MDNSent|\\\*).*/i', $read[$num] );
155 if ( ereg('PERMANENTFLAGS', $read[$num] ) ) {
156 $ret = ( ereg('mdnsent',strtolower($read[$num]) ) || ereg("\\\*", $read[$num] ) );
164 function SendMDN ( $recipient , $sender) {
165 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
166 $version, $attachments, $identity, $data_dir, $passed_id;
168 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
169 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
173 $senton = getLongDateString( $header->date
);
174 $to_array = $header->to
;
176 foreach ($to_array as $line) {
180 $subject = $header->subject
;
181 $now = getLongDateString( time() );
183 $body = _("Your message") . "\r\n\r\n" .
184 "\t" . _("To:") . ' ' . $to . "\r\n" .
185 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
186 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
188 sprintf( _("Was displayed on %s"), $now );
190 $body = sprintf( _("This message sent on %s to %s with subject \"%s\" has been displayed on %s."),
191 $senton, $to, $subject, $now ) .
193 _("This is no guarantee that the message has been read or understood.") . "\r\n";
197 $original_recipient = $to;
198 $original_message_id = $header->message_id
;
200 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
201 if ($original_recipient != '') {
202 $part2 .= "Original-Recipient : $original_recipient\r\n";
204 $final_recipient = $sender;
205 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
206 "Original-Message-ID : $original_message_id\r\n" .
207 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
210 $localfilename = GenerateRandomString(32, 'FILE', 7);
211 $full_localfilename = "$hashed_attachment_dir/$localfilename";
213 $fp = fopen( $full_localfilename, 'w');
214 fwrite ($fp, $part2);
217 $newAttachment = array();
218 $newAttachment['localfilename'] = $localfilename;
219 $newAttachment['type'] = "message/disposition-notification";
221 $attachments[] = $newAttachment;
222 $MDN_to = trim($recipient);
225 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3) );
229 function ToggleMDNflag ( $set ) {
231 global $imapConnection, $passed_id, $mailbox;
240 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
241 sqimap_mailbox_select($imapConnection, $mailbox);
242 $read = sqimap_run_command ($imapConnection, $cmd, true, $response, $readmessage);
246 function ClearAttachments() {
247 global $username, $attachments, $attachment_dir;
249 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
251 foreach ($attachments as $info) {
252 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
253 if (file_exists($attached_file)) {
254 unlink($attached_file);
258 $attachments = array();
263 * Main of read_boby.php --------------------------------------------------
272 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
273 $read = sqimap_mailbox_select($imapConnection, $mailbox);
278 * The following code sets necesarry stuff for the MDN thing
280 if( $default_use_mdn &&
281 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
283 $supportMDN = ServerMDNSupport($read);
284 $flags = sqimap_get_flags ($imapConnection, $passed_id);
285 $FirstTimeSee = !(in_array( 'Seen', $flags ));
288 displayPageHeader($color, $mailbox);
292 * The following code shows the header of the message and then exit
294 if (isset($view_hdr)) {
295 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
298 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
299 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\"><CENTER><B>" . _("Viewing Full Header") . '</B> - '.
300 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
301 if (isset($where) && isset($what)) {
302 // Got here from a search
303 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
305 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
307 echo _("View message") . "</a></b></center></td></tr></table>\n" .
308 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
312 for ($i=1; $i < count($read); $i++
) {
313 $line = htmlspecialchars($read[$i]);
314 if (eregi("^>", $line)) {
316 $first[$i] = ' ';
318 } else if (eregi("^[ |\t]", $line)) {
321 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
322 $first[$i] = $regs[1] . ':';
323 $second[$i] = $regs[2];
326 $second[$i] = trim($line);
330 for ($i=0; $i < count($second); $i = $j) {
331 if (isset($first[$i])) {
334 if (isset($second[$i])) {
335 $s = nl2br($second[$i]);
338 while (($first[$j] == '') && ($j < count($first))) {
339 $s .= ' ' . nl2br($second[$j]);
343 if (isset($f)) echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
345 echo "</td></tr></table>\n" .
347 sqimap_logout($imapConnection);
352 $currentArrayIndex = $passed_id;
354 $currentArrayIndex = -1;
357 for ($i = 0; $i < count($msgs); $i++
) {
358 if ($msgs[$i]['ID'] == $passed_id) {
359 $msgs[$i]['FLAG_SEEN'] = true;
363 // $message contains all information about the message
364 // including header and body
365 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
367 /** translate the subject and mailbox into url-able text **/
368 $url_subj = urlencode(trim($message->header
->subject
));
369 $urlMailbox = urlencode($mailbox);
371 if (isset($message->header
->replyto
)) {
372 $url_replyto = urlencode($message->header
->replyto
);
375 $url_replytoall = $url_replyto;
377 // If we are replying to all, then find all other addresses and
378 // add them to the list. Remove duplicates.
379 // This is somewhat messy, so I'll explain:
380 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
381 $url_replytoall_extra_addrs = array_merge(
382 array($message->header
->from
),
383 $message->header
->to
,
387 // 2) Make one big string out of them
388 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
390 // 3) Parse that into an array of addresses
391 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
393 // 4) Make them unique -- weed out duplicates
394 // (Coded for PHP 4.0.0)
395 $url_replytoall_extra_addrs =
396 array_keys(array_flip($url_replytoall_extra_addrs));
398 // 5) Remove the addresses we'll be sending the message 'to'
399 $url_replytoall_avoid_addrs = '';
400 if (isset($message->header
->replyto
)) {
401 $url_replytoall_avoid_addrs = $message->header
->replyto
;
404 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
405 foreach ($url_replytoall_avoid_addrs as $addr) {
406 RemoveAddress($url_replytoall_extra_addrs, $addr);
409 // 6) Remove our identities from the CC list (they still can be in the
410 // TO list) only if $include_self_reply_all is turned off
411 if (!$include_self_reply_all) {
412 RemoveAddress($url_replytoall_extra_addrs,
413 getPref($data_dir, $username, 'email_address'));
414 $idents = getPref($data_dir, $username, 'identities');
415 if ($idents != '' && $idents > 1) {
416 for ($i = 1; $i < $idents; $i ++
) {
417 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
418 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
423 // 7) Smoosh back into one nice line
424 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
427 $url_replytoallcc = urlencode($url_replytoallcc);
429 $dateString = getLongDateString($message->header
->date
);
431 // What do we reply to -- text only, if possible
432 $ent_num = findDisplayEntity($message);
434 /** TEXT STRINGS DEFINITIONS **/
435 $echo_more = _("more");
436 $echo_less = _("less");
438 if (!isset($show_more_cc)) {
439 $show_more_cc = FALSE;
442 /** FORMAT THE TO STRING **/
445 $to_ary = $message->header
->to
;
446 while ($i < count($to_ary)) {
447 $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i]));
450 $to_string = "$to_string<BR>$to_ary[$i]";
452 $to_string = "$to_ary[$i]";
456 if (count($to_ary) > 1) {
457 if ($show_more == false) {
459 /* From a search... */
460 $to_string .= ' (<A HREF="' . $base_uri .
461 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
462 if (isset($where) && isset($what)) {
463 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
465 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
469 } else if ($i == 1) {
470 /* From a search... */
471 $to_string .= ' (<A HREF="' . $base_uri .
472 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
473 if (isset($where) && isset($what)) {
474 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
476 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
482 /** FORMAT THE CC STRING **/
484 if (isset ($message->header
->cc
[0]) && trim($message->header
->cc
[0])) {
486 $cc_ary = $message->header
->cc
;
487 while ($i < count(decodeHeader($cc_ary))) {
488 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
490 $cc_string = "$cc_string<BR>$cc_ary[$i]";
492 $cc_string = "$cc_ary[$i]";
496 if (count($cc_ary) > 1) {
497 if ($show_more_cc == false) {
499 /* From a search... */
500 $cc_string .= ' (<A HREF="' . $base_uri .
501 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id";
502 if (isset($where) && isset($what)) {
503 $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
505 $cc_string .= "&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
509 } else if ($i == 1) {
510 /* From a search... */
511 $cc_string .= ' (<A HREF="' . $base_uri .
512 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
513 if (isset($where) && isset($what)) {
514 $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
516 $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
526 /** FORMAT THE BCC STRING **/
528 if (isset ($message->header
->bcc
[0]) && trim($message->header
->bcc
[0])){
530 $bcc_ary = $message->header
->bcc
;
531 while ($i < count(decodeHeader($bcc_ary))) {
532 $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]);
534 $bcc_string = "$bcc_string<BR>$bcc_ary[$i]";
536 $bcc_string = "$bcc_ary[$i]";
540 if (count($bcc_ary) > 1) {
541 if ($show_more_cc == false) {
543 /* From a search... */
544 $bcc_string .= ' (<A HREF="' . $base_uri .
545 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
546 if (isset($where) && isset($what)) {
547 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
549 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
551 $i = count($bcc_ary);
553 } else if ($i == 1) {
554 /* From a search... */
555 $bcc_string .= ' (<A HREF="' . $base_uri .
556 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
557 if (isset($where) && isset($what)) {
558 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
560 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
570 if ($default_use_priority) {
571 $priority_level = substr($message->header
->priority
,0,1);
573 switch($priority_level) {
574 /* check for a higher then normal priority. */
577 $priority_string = _("High");
580 /* check for a lower then normal priority. */
583 $priority_string = _("Low");
586 /* check for a normal priority. */
589 $priority_level = '3';
590 $priority_string = _("Normal");
596 /** make sure everything will display in HTML format **/
597 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
598 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
600 do_hook('read_body_top');
602 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
603 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
604 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
606 '<TD ALIGN="LEFT" WIDTH="33%">' .
608 '<A HREF="' . $base_uri . 'src/';
610 if ($where && $what) {
614 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
616 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
618 echo _("Message List") .
619 '</A> | ' .
620 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
621 if ($where && $what) {
622 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
624 echo "sort=$sort&startMessage=$startMessage\">";
626 echo _("Delete") . '</A> ';
627 if (($mailbox == $draft_folder) && ($save_as_draft)) {
628 echo '| <A HREF="' . $base_uri .
629 "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\"";
630 if ($compose_new_win == '1') {
631 echo 'TARGET="compose_window" onClick="comp_in_new()"';
634 _("Resume Draft") . '</a>';
637 echo ' ' .
640 '<TD WIDTH="33%" ALIGN="CENTER">' .
643 if ( !($where && $what) ) {
645 if ($currentArrayIndex == -1) {
646 echo 'Previous | Next';
648 $prev = findPreviousMessage();
649 $next = findNextMessage();
652 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
654 echo _("Previous") . ' | ';
658 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
666 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
668 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
669 ($default_use_priority?
"mailprio=$priority_level&":"")
670 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
671 if ($compose_new_win == '1') {
672 echo 'TARGET="compose_window" onClick="comp_in_new()"';
676 '</A> | ' .
677 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
678 ($default_use_priority?
"mailprio=$priority_level&":"").
679 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
680 if ($compose_new_win == '1') {
681 echo 'TARGET="compose_window" onClick="comp_in_new()"';
685 '</A> | ' .
686 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
687 ($default_use_priority?
"mailprio=$priority_level&":"").
688 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
689 if ($compose_new_win == '1') {
690 echo 'TARGET="compose_window" onClick="comp_in_new()"';
700 '<TR><TD CELLSPACING="0" WIDTH="100%">' .
701 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
705 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
707 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
708 "<B>$subject</B> \n" .
710 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
711 '" ALIGN=right VALIGN=top NOWRAP><small>'.
712 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
714 /* From a search... */
715 if ($where && $what) {
716 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
717 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
719 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
720 _("View Full Header") . "</A>\n";
723 /* Output the printer friendly link if we are in subtle mode. */
724 if ($pf_subtle_link) {
725 echo printer_friendly_link(true);
728 do_hook("read_body_header_right");
729 echo '</small></TD>' .
734 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
736 '</TD><TD BGCOLOR="' . $color[0] . '">' .
737 "<B>$from_name</B> \n" .
742 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
744 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
745 "<B>$dateString</B> \n" .
751 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
753 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
754 "<B>$to_string</B> \n" .
758 if (isset($cc_string)) {
760 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
762 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
763 "<B>$cc_string</B> " .
769 if (isset($bcc_string)) {
771 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
773 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
774 "<B>$bcc_string</B> " .
778 if ($default_use_priority) {
779 if (isset($priority_string)) {
781 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
782 _("Priority") . ': '.
783 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
784 "<B>$priority_string</B> " .
790 if ($show_xmailer_default) {
791 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
792 $response, $readmessage);
793 $mailer = substr($read[1], strpos($read[1], " "));
796 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
798 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
799 "<B>$mailer</B> " .
805 /* Output the printer friendly link if we are not in subtle mode. */
806 if (!$pf_subtle_link) {
807 echo printer_friendly_link(true);
810 if ($default_use_mdn) {
811 if ($mdn_user_support) {
813 // debug gives you the capability to remove mdn-flags
815 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
816 $response, $readmessage);
817 $MDN_to = substr($read[1], strpos($read[1], ' '));
818 $MDN_flag_present = false;
820 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
821 $response, $readmessage);
823 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
826 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
828 if ( $MDN_flag_present && $supportMDN) {
829 $sendreceipt = 'removeMDN';
830 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
834 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
835 _("Read receipt") . ': ' .
836 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
839 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
844 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
845 _("Read receipt") . ': ' .
846 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
847 '<B>'._("send").'</B>'.
852 } // when deleted or draft flag is set don't offer to send a MDN response
853 else if ( ereg('Draft',$read[0] ||
ereg('Deleted',$read[0])) ) {
855 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
856 _("Read receipt") . ': '.
857 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
858 '<B>' . _("requested") . "</B>" .
862 // if no MDNsupport don't use the annoying popup messages
863 else if ( !$FirstTimeSee ) {
864 $sendreceipt = 'send';
865 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
867 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
868 _("Read receipt") . ': ' .
869 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
870 '<B>' . _("requested") .
871 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
877 $sendreceipt = 'send';
878 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
879 if ($javascript_on) {
880 echo "<script language=\"javascript\"> \n" .
882 " if (window.confirm(\"" .
883 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
885 " window.location=($url); \n" .
886 ' window.reload()' . "\n" .
892 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
893 _("Read receipt") . ': ' .
894 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
895 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
896 _("Send read receipt now") . '] </a>' ." \n" .
903 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
904 } else if ( $sendreceipt == 'send' ) {
905 if ( !$MDN_flag_present) {
906 if (isset($identity) ) {
907 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
909 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
912 $final_recipient = trim($final_recipient);
913 if ($final_recipient == '' ) {
914 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
917 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
918 ToggleMDNflag( true);
921 $sendreceipt = 'removeMDN';
922 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
925 if ($debug && $supportMDN) {
927 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
928 " "._("Read receipt").": \n".
929 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
930 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
935 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
936 " "._("Read receipt").": \n".
937 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
938 ' <B>'._("send").'</B>'. "\n" .
943 elseif ($sendreceipt == 'removeMDN' ) {
944 ToggleMDNflag ( false );
946 $sendreceipt = 'send';
947 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
949 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
950 _("Read receipt") . ': ' .
951 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
952 '<B>' . _("requested") .
953 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
962 do_hook('read_body_header');
969 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
970 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
972 formatBody($imapConnection, $message, $color, $wrap_at).
974 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
975 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
978 /* show attached images inline -- if pref'fed so */
979 if (($attachment_common_show_images) &&
980 is_array($attachment_common_show_images_list)) {
982 foreach ($attachment_common_show_images_list as $img) {
983 $imgurl = '../src/download.php' .
985 'passed_id=' . urlencode($img['passed_id']) .
986 '&mailbox=' . urlencode($mailbox) .
987 '&passed_ent_id=' . urlencode($img['ent_id']) .
990 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
993 "<img src=\"$imgurl\">\n" .
1002 do_hook('read_body_bottom');
1003 do_hook('html_bottom');
1004 sqimap_logout($imapConnection);