56563bab8f350ee6f5fd1dcf25c5f168a007b733
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" type="text/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 ) {
142 /* escaping $ doesn't work -> \x36 */
143 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
147 function SendMDN ( $recipient , $sender) {
148 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
149 $version, $attachments, $identity, $data_dir, $passed_id;
151 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
152 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
156 $senton = getLongDateString( $header->date
);
157 $to_array = $header->to
;
159 foreach ($to_array as $line) {
163 $subject = $header->subject
;
164 $now = getLongDateString( time() );
166 $body = _("Your message") . "\r\n\r\n" .
167 "\t" . _("To:") . ' ' . $to . "\r\n" .
168 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
169 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
171 sprintf( _("Was displayed on %s"), $now );
175 $original_recipient = $to;
176 $original_message_id = $header->message_id
;
178 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
179 if ($original_recipient != '') {
180 $part2 .= "Original-Recipient : $original_recipient\r\n";
182 $final_recipient = $sender;
183 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
184 "Original-Message-ID : $original_message_id\r\n" .
185 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
188 $localfilename = GenerateRandomString(32, 'FILE', 7);
189 $full_localfilename = "$hashed_attachment_dir/$localfilename";
191 $fp = fopen( $full_localfilename, 'w');
192 fwrite ($fp, $part2);
195 $newAttachment = array();
196 $newAttachment['localfilename'] = $localfilename;
197 $newAttachment['type'] = "message/disposition-notification";
199 $attachments[] = $newAttachment;
200 $MDN_to = trim($recipient);
203 return (SendMessage($MDN_to,'','', _("Read:") . ' ' . $subject, $body,$reply_id, True, 3) );
207 function ToggleMDNflag ( $set ) {
208 global $imapConnection, $passed_id, $mailbox;
209 sqimap_mailbox_select($imapConnection, $mailbox);
212 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
213 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
217 function ClearAttachments() {
218 global $username, $attachments, $attachment_dir;
220 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
222 foreach ($attachments as $info) {
223 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
224 if (file_exists($attached_file)) {
225 unlink($attached_file);
229 $attachments = array();
234 * Main of read_boby.php --------------------------------------------------
243 if ( isset( $mailbox ) ) {
244 $mailbox = urldecode( $mailbox );
246 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
247 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
252 * The following code sets necesarry stuff for the MDN thing
254 if( $default_use_mdn &&
255 ( $mdn_user_support = getPref($data_dir, $username, 'mdn_user_support', $default_use_mdn) ) ) {
257 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
258 $flags = sqimap_get_flags ($imapConnection, $passed_id);
259 $FirstTimeSee = !(in_array( 'Seen', $flags ));
262 displayPageHeader($color, $mailbox);
266 * The following code shows the header of the message and then exit
268 if (isset($view_hdr)) {
269 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]", true, $a, $b);
272 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0" ALIGN="CENTER">' . "\n" .
273 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>" . _("Viewing Full Header") . '</B> - '.
274 '<a href="' . $base_uri . "src/read_body.php?mailbox=".urlencode($mailbox);
275 if (isset($where) && isset($what)) {
276 // Got here from a search
277 echo "&passed_id=$passed_id&where=".urlencode($where)."&what=".urlencode($what).'">';
279 echo "&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more\">";
281 echo _("View message") . "</a></b></td></tr></table>\n" .
282 "<table width=\"99%\" cellpadding=2 cellspacing=0 border=0 align=center>\n" .
286 for ($i=1; $i < count($read); $i++
) {
287 $line = htmlspecialchars($read[$i]);
288 if (eregi("^>", $line)) {
290 $first[$i] = ' ';
292 } else if (eregi("^[ |\t]", $line)) {
295 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
296 $first[$i] = $regs[1] . ':';
297 $second[$i] = $regs[2];
300 $second[$i] = trim($line);
304 for ($i=0; $i < count($second); $i = $j) {
305 if (isset($first[$i])) {
308 if (isset($second[$i])) {
309 $s = nl2br($second[$i]);
312 while (($first[$j] == '') && ($j < count($first))) {
313 $s .= ' ' . nl2br($second[$j]);
318 echo "<nobr><tt><b>$f</b>$s</tt></nobr>";
321 echo "</td></tr></table>\n" .
323 sqimap_logout($imapConnection);
328 $currentArrayIndex = $passed_id;
330 $currentArrayIndex = -1;
333 for ($i = 0; $i < count($msgs); $i++
) {
334 if ($msgs[$i]['ID'] == $passed_id) {
335 $msgs[$i]['FLAG_SEEN'] = true;
339 // $message contains all information about the message
340 // including header and body
341 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
343 /** translate the subject and mailbox into url-able text **/
344 $url_subj = urlencode(trim($message->header
->subject
));
345 $urlMailbox = urlencode($mailbox);
347 if (isset($message->header
->replyto
)) {
348 $url_replyto = urlencode($message->header
->replyto
);
351 $url_replytoall = $url_replyto;
353 // If we are replying to all, then find all other addresses and
354 // add them to the list. Remove duplicates.
355 // This is somewhat messy, so I'll explain:
356 // 1) Take all addresses (from, to, cc) (avoid nasty join errors here)
357 $url_replytoall_extra_addrs = array_merge(
358 array($message->header
->from
),
359 $message->header
->to
,
363 // 2) Make one big string out of them
364 $url_replytoall_extra_addrs = join(';', $url_replytoall_extra_addrs);
366 // 3) Parse that into an array of addresses
367 $url_replytoall_extra_addrs = parseAddrs($url_replytoall_extra_addrs);
369 // 4) Make them unique -- weed out duplicates
370 // (Coded for PHP 4.0.0)
371 $url_replytoall_extra_addrs =
372 array_keys(array_flip($url_replytoall_extra_addrs));
374 // 5) Remove the addresses we'll be sending the message 'to'
375 $url_replytoall_avoid_addrs = '';
376 if (isset($message->header
->replyto
)) {
377 $url_replytoall_avoid_addrs = $message->header
->replyto
;
380 $url_replytoall_avoid_addrs = parseAddrs($url_replytoall_avoid_addrs);
381 foreach ($url_replytoall_avoid_addrs as $addr) {
382 RemoveAddress($url_replytoall_extra_addrs, $addr);
385 // 6) Remove our identities from the CC list (they still can be in the
386 // TO list) only if $include_self_reply_all is turned off
387 if (!$include_self_reply_all) {
388 RemoveAddress($url_replytoall_extra_addrs,
389 getPref($data_dir, $username, 'email_address'));
390 $idents = getPref($data_dir, $username, 'identities');
391 if ($idents != '' && $idents > 1) {
392 for ($i = 1; $i < $idents; $i ++
) {
393 $cur_email_address = getPref($data_dir, $username, 'email_address' . $i);
394 RemoveAddress($url_replytoall_extra_addrs, $cur_email_address);
399 // 7) Smoosh back into one nice line
400 $url_replytoallcc = getLineOfAddrs($url_replytoall_extra_addrs);
403 $url_replytoallcc = urlencode($url_replytoallcc);
405 $dateString = getLongDateString($message->header
->date
);
407 // What do we reply to -- text only, if possible
408 $ent_num = findDisplayEntity($message);
410 /** TEXT STRINGS DEFINITIONS **/
411 $echo_more = _("more");
412 $echo_less = _("less");
414 if (!isset($show_more_cc)) {
415 $show_more_cc = FALSE;
418 /** FORMAT THE TO STRING **/
422 $to_ary = $message->header
->to
;
423 while ($i < count($to_ary)) {
424 $to_ary[$i] = htmlspecialchars(decodeHeader($to_ary[$i]));
425 $url_to_string .= $to_ary[$i];
428 $to_string = "$to_string<BR>$to_ary[$i]";
430 $to_string = "$to_ary[$i]";
434 if (count($to_ary) > 1) {
435 if ($show_more == false) {
437 /* From a search... */
438 $to_string .= ' (<A HREF="' . $base_uri .
439 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
440 if (isset($where) && isset($what)) {
441 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
443 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=1&show_more_cc=$show_more_cc\">$echo_more</A>)";
447 } else if ($i == 1) {
448 /* From a search... */
449 $to_string .= ' (<A HREF="' . $base_uri .
450 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
451 if (isset($where) && isset($what)) {
452 $to_string .= 'where='.urlencode($where)."&what=".urlencode($what)."&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
454 $to_string .= "sort=$sort&startMessage=$startMessage&show_more=0&show_more_cc=$show_more_cc\">$echo_less</A>)";
459 $url_to_string = urlencode($url_to_string);
462 /** FORMAT THE CC STRING **/
465 if (isset ($message->header
->cc
[0]) && trim($message->header
->cc
[0])) {
467 $cc_ary = $message->header
->cc
;
468 while ($i < count(decodeHeader($cc_ary))) {
469 $cc_ary[$i] = htmlspecialchars($cc_ary[$i]);
470 $url_cc_string .= $cc_ary[$i];
473 $cc_string = "$cc_string<BR>$cc_ary[$i]";
475 $cc_string = "$cc_ary[$i]";
479 if (count($cc_ary) > 1) {
480 if ($show_more_cc == false) {
482 /* From a search... */
483 $cc_string .= ' (<A HREF="' . $base_uri .
484 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id";
485 if (isset($where) && isset($what)) {
486 $cc_string .= '&what='.urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
488 $cc_string .= "&sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
492 } else if ($i == 1) {
493 /* From a search... */
494 $cc_string .= ' (<A HREF="' . $base_uri .
495 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
496 if (isset($where) && isset($what)) {
497 $cc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
499 $cc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
508 $url_cc_string = urlencode($url_cc_string);
510 /** FORMAT THE BCC STRING **/
512 $url_bcc_string = '';
513 if (isset ($message->header
->bcc
[0]) && trim($message->header
->bcc
[0])){
515 $bcc_ary = $message->header
->bcc
;
516 while ($i < count(decodeHeader($bcc_ary))) {
517 $bcc_ary[$i] = htmlspecialchars($bcc_ary[$i]);
518 $url_bcc_string .= $bcc_ary[$i];
520 $bcc_string = "$bcc_string<BR>$bcc_ary[$i]";
522 $bcc_string = "$bcc_ary[$i]";
526 if (count($bcc_ary) > 1) {
527 if ($show_more_cc == false) {
529 /* From a search... */
530 $bcc_string .= ' (<A HREF="' . $base_uri .
531 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
532 if (isset($where) && isset($what)) {
533 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
535 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=1&show_more=$show_more\">$echo_more</A>)";
537 $i = count($bcc_ary);
539 } else if ($i == 1) {
540 /* From a search... */
541 $bcc_string .= ' (<A HREF="' . $base_uri .
542 "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
543 if (isset($where) && isset($what)) {
544 $bcc_string .= 'what=' . urlencode($what)."&where=".urlencode($where)."&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
546 $bcc_string .= "sort=$sort&startMessage=$startMessage&show_more_cc=0&show_more=$show_more\">$echo_less</A>)";
555 $url_bcc_string = urlencode($url_bcc_string);
557 if ($default_use_priority) {
558 $priority_level = substr($message->header
->priority
,0,1);
560 switch($priority_level) {
561 /* check for a higher then normal priority. */
564 $priority_string = _("High");
567 /* check for a lower then normal priority. */
570 $priority_string = _("Low");
573 /* check for a normal priority. */
576 $priority_level = '3';
577 $priority_string = _("Normal");
583 /** make sure everything will display in HTML format **/
584 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
585 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
587 do_hook('read_body_top');
589 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
590 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
591 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
593 '<TD ALIGN="LEFT" WIDTH="33%">' .
595 '<A HREF="' . $base_uri . 'src/';
597 if ($where && $what) {
601 echo "search.php?where$pos=".urlencode($where)."&pos=$pos&what$pos=".urlencode($what)."&mailbox=$urlMailbox\">";
603 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
605 echo _("Message List") .
606 '</A> | ' .
607 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
608 if ($where && $what) {
609 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
611 echo "sort=$sort&startMessage=$startMessage\">";
613 echo _("Delete") . '</A> ';
614 if (($mailbox == $draft_folder) && ($save_as_draft)) {
615 echo '| <A HREF="' . $base_uri .
616 "src/compose.php?mailbox=$mailbox&send_to=$url_to_string&send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&subject=$url_subj&draft_id=$passed_id&ent_num=$ent_num" . '"';
617 if ($compose_new_win == '1') {
618 echo 'TARGET="compose_window" onClick="comp_in_new()"';
621 _("Resume Draft") . '</a>';
624 echo ' ' .
627 '<TD WIDTH="33%" ALIGN="CENTER">' .
630 if ( !($where && $what) ) {
632 if ($currentArrayIndex == -1) {
633 echo 'Previous | Next';
635 $prev = findPreviousMessage();
636 $next = findNextMessage();
639 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
641 echo _("Previous") . ' | ';
645 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
653 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
655 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
656 ($default_use_priority?
"mailprio=$priority_level&":'')
657 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
658 if ($compose_new_win == '1') {
659 echo 'TARGET="compose_window" onClick="comp_in_new()"';
663 '</A> | ' .
664 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
665 ($default_use_priority?
"mailprio=$priority_level&":'').
666 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
667 if ($compose_new_win == '1') {
668 echo 'TARGET="compose_window" onClick="comp_in_new()"';
672 '</A> | ' .
673 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
674 ($default_use_priority?
"mailprio=$priority_level&":'').
675 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
676 if ($compose_new_win == '1') {
677 echo 'TARGET="compose_window" onClick="comp_in_new()"';
687 '<TR><TD WIDTH="100%">' .
688 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
692 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
694 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
695 "<B>$subject</B> \n" .
697 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
698 '" ALIGN=right VALIGN=top NOWRAP><small>'.
699 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
701 /* From a search... */
702 if ($where && $what) {
703 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
704 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
706 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
707 _("View Full Header") . "</A>\n";
710 /* Output the printer friendly link if we are in subtle mode. */
711 if ($pf_subtle_link) {
712 echo printer_friendly_link(true);
715 do_hook("read_body_header_right");
716 echo '</small></TD>' .
721 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
723 '</TD><TD BGCOLOR="' . $color[0] . '">' .
724 "<B>$from_name</B> \n" .
729 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
731 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
732 "<B>$dateString</B> \n" .
738 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
740 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
741 "<B>$to_string</B> \n" .
745 if (isset($cc_string) && $cc_string <> '') {
747 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
749 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
750 "<B>$cc_string</B> " .
756 if (isset($bcc_string) && $bcc_string <> '') {
758 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
760 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
761 "<B>$bcc_string</B> " .
765 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
767 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
768 _("Priority") . ': '.
769 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
770 "<B>$priority_string</B> " .
775 if ($show_xmailer_default) {
776 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
777 $response, $readmessage);
778 $mailer = substr($read[1], strpos($read[1], " "));
781 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
783 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
784 "<B>$mailer</B> " .
790 /* Output the printer friendly link if we are not in subtle mode. */
791 if (!$pf_subtle_link) {
792 echo printer_friendly_link(true);
795 if ($default_use_mdn) {
796 if ($mdn_user_support) {
798 // debug gives you the capability to remove mdn-flags
799 // $MDNDebug = false;
800 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
801 $response, $readmessage);
802 $MDN_to = substr($read[1], strpos($read[1], ' '));
803 $MDN_flag_present = false;
805 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
806 $response, $readmessage);
808 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
811 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
813 if ( $MDN_flag_present && $supportMDN) {
814 $sendreceipt = 'removeMDN';
815 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
820 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
821 _("Read receipt") . ': ' .
822 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
825 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
831 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
832 _("Read receipt") . ': ' .
833 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
834 '<B>'._("send").'</B>'.
841 } // when deleted or draft flag is set don't offer to send a MDN response
842 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
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") . "</B>" .
851 // if no MDNsupport don't use the annoying popup messages
852 else if ( !$FirstTimeSee ) {
853 $sendreceipt = 'send';
854 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
856 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
857 _("Read receipt") . ': ' .
858 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
859 '<B>' . _("requested") .
860 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
866 $sendreceipt = 'send';
867 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
868 if ($javascript_on) {
869 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
871 " if (window.confirm(\"" .
872 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
874 " window.location=($url); \n" .
875 ' window.reload()' . "\n" .
881 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
882 _("Read receipt") . ': ' .
883 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
884 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
885 _("Send read receipt now") . '] </a>' ." \n" .
892 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
893 } else if ( $sendreceipt == 'send' ) {
894 if ( !$MDN_flag_present) {
895 if (isset($identity) ) {
896 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
898 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
901 $final_recipient = trim($final_recipient);
902 if ($final_recipient == '' ) {
903 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
906 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
907 ToggleMDNflag( true);
910 $sendreceipt = 'removeMDN';
911 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
914 if ($MDNDebug && $supportMDN) {
916 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
917 " "._("Read receipt").": \n".
918 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
919 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
925 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
926 " "._("Read receipt").": \n".
927 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
928 ' <B>'._("send").'</B>'. "\n" .
935 elseif ($sendreceipt == 'removeMDN' ) {
936 ToggleMDNflag ( false );
938 $sendreceipt = 'send';
939 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
941 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
942 _("Read receipt") . ': ' .
943 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
944 '<B>' . _("requested") .
945 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
954 do_hook('read_body_header');
961 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
962 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
964 formatBody($imapConnection, $message, $color, $wrap_at).
965 '</TD></TR></TABLE>' .
966 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
967 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
970 /* show attached images inline -- if pref'fed so */
971 if (($attachment_common_show_images) &&
972 is_array($attachment_common_show_images_list)) {
974 foreach ($attachment_common_show_images_list as $img) {
975 $imgurl = '../src/download.php' .
977 'passed_id=' . urlencode($img['passed_id']) .
978 '&mailbox=' . urlencode($mailbox) .
979 '&passed_ent_id=' . urlencode($img['ent_id']) .
980 '&absolute_dl=true';
982 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
985 "<img src=\"$imgurl\">\n" .
994 do_hook('read_body_bottom');
995 do_hook('html_bottom');
996 sqimap_logout($imapConnection);