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 = '<tr bgcolor="' . $color[0] . '">' .
160 '<td class="medText" align="right" valign="top">' .
162 '</td><td class="medText" valign="top" colspan="2">'."\n";
164 /* The link is subtle, below "view full header". */
168 /* Output the link. */
169 if ($javascript_on) {
170 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
172 " function printFormat() {\n" .
173 ' window.open("../src/printer_friendly_main.php' .
174 $params . '","Print","width=800,height=600");' . "\n".
178 "<A HREF=\"javascript:printFormat();\">$print_text</A>\n";
180 $result .= '<A TARGET="_blank" HREF="../src/printer_friendly_bottom.php' .
181 "$params\">$print_text</A>\n";
184 if (!$pf_subtle_link) {
185 /* The link is large, on the bottom of the header panel. */
186 $result .= '</td></tr>' . "\n";
192 function ServerMDNSupport( $read ) {
193 /* escaping $ doesn't work -> \x36 */
194 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
198 function SendMDN ( $recipient , $sender) {
199 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
200 $version, $attachments, $identity, $data_dir, $passed_id;
202 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
203 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
207 $senton = getLongDateString( $header->date
);
208 $to_array = $header->to
;
210 foreach ($to_array as $line) {
214 $subject = $header->subject
;
215 $now = getLongDateString( time() );
219 $body = _("Your message") . "\r\n\r\n" .
220 "\t" . _("To:") . ' ' . $to . "\r\n" .
221 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
222 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
224 sprintf( _("Was displayed on %s"), $now );
228 $original_recipient = $to;
229 $original_message_id = $header->message_id
;
231 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
232 if ($original_recipient != '') {
233 $part2 .= "Original-Recipient : $original_recipient\r\n";
235 $final_recipient = $sender;
236 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
237 "Original-Message-ID : $original_message_id\r\n" .
238 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
241 $localfilename = GenerateRandomString(32, 'FILE', 7);
242 $full_localfilename = "$hashed_attachment_dir/$localfilename";
244 $fp = fopen( $full_localfilename, 'w');
245 fwrite ($fp, $part2);
248 $newAttachment = array();
249 $newAttachment['localfilename'] = $localfilename;
250 $newAttachment['type'] = "message/disposition-notification";
251 $newAttachment['session']=-1;
252 $attachments[] = $newAttachment;
253 $MDN_to = trim($recipient);
256 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
257 $body, $reply_id, True, 3, -1) );
261 function ToggleMDNflag ( $set ) {
262 global $imapConnection, $passed_id, $mailbox;
263 sqimap_mailbox_select($imapConnection, $mailbox);
266 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
267 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
271 function ClearAttachments() {
272 global $username, $attachments, $attachment_dir;
274 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
276 $rem_attachments = array();
277 foreach ($attachments as $info) {
278 if ($info->session
== -1) {
279 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
280 if (file_exists($attached_file)) {
281 unlink($attached_file);
284 $rem_attachments[] = $info;
287 $attachments = $rem_attachments;
290 function formatRecipientString($recipients, $item ) {
291 global $base_uri, $passed_id, $urlMailbox, $startMessage, $show_more_cc,
292 $echo_more, $echo_less, $show_more, $show_more_bcc, $sort;
297 if (isset ($recipients[0]) && trim($recipients[0])) {
303 $show = "&show_more=1&show_more_cc=$show_more_cc&".
304 "show_more_bcc=$show_more_bcc";
305 $show_n = "&show_more=0&show_more_cc=$show_more_cc&".
306 "show_more_bcc=$show_more_bcc";
309 $show = "&show_more=$show_more&show_more_cc=1&".
310 "show_more_bcc=$show_more_bcc";
311 $show_n = "&show_more=$show_more&show_more_cc=0&".
312 "show_more_bcc=$show_more_bcc";
313 $show_more = $show_more_cc;
316 $show = "&show_more=$show_more&show_more_cc=$show_more_cc".
317 "&show_more_bcc=1";
318 $show_n = "&show_more=$show_more&show_more_cc=".
319 "$show_more_cc&show_more_bcc=0";
320 $show_more = $show_more_bcc;
326 while ($i < count($ary)) {
327 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
328 $url_string .= $ary[$i];
330 $string = "$string<BR>$ary[$i]";
332 $string = "$ary[$i]";
336 if (count($ary) > 1) {
337 if ($show_more == false) {
339 /* From a search... */
340 $string .= ' (<A HREF="' . $base_uri .
341 "src/read_body.php?mailbox=$urlMailbox&".
342 "passed_id=$passed_id&";
343 if (isset($where) && isset($what)) {
344 $string .= 'what=' . urlencode($what).
345 "&where=".urlencode($where).
346 "$show\">$echo_more</A>)";
348 $string .= "sort=$sort&startMessage=".
349 "$startMessage"."$show\">$echo_more</A>)";
353 } else if ($i == 1) {
354 /* From a search... */
355 $string .= ' (<A HREF="' . $base_uri .
356 "src/read_body.php?mailbox=$urlMailbox&".
357 "passed_id=$passed_id&";
358 if (isset($where) && isset($what)) {
359 $string .= 'what=' . urlencode($what).
360 "&where=".urlencode($where).
361 "$show_n\">$echo_less</A>)";
363 $string .= "sort=$sort&startMessage=$startMessage".
364 "$show_n\">$echo_less</A>)";
373 $url_string = urlencode($url_string);
375 $result['str'] = $string;
376 $result['url_str'] = $url_string;
383 * Main of read_boby.php --------------------------------------------------
392 if (isset($mailbox)){
393 $mailbox = urldecode( $mailbox );
395 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
397 $read = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
402 * The following code sets necesarry stuff for the MDN thing
404 if($default_use_mdn &&
405 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
406 $default_use_mdn))) {
408 $supportMDN = ServerMDNSupport($read["PERMANENTFLAGS"]);
409 $flags = sqimap_get_flags ($imapConnection, $passed_id);
410 $FirstTimeSee = !(in_array( 'Seen', $flags ));
413 displayPageHeader($color, $mailbox);
417 * The following code shows the header of the message and then exit
419 if (isset($view_hdr)) {
420 $read=sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[HEADER]",
424 '<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BORDER="0"'.
425 ' ALIGN="CENTER">' . "\n" .
426 " <TR><TD BGCOLOR=\"$color[9]\" WIDTH=\"100%\" ALIGN=\"CENTER\"><B>".
427 _("Viewing Full Header") . '</B> - '.
428 '<a href="' . $base_uri . 'src/read_body.php?mailbox='.
430 if (isset($where) && isset($what)) {
431 // Got here from a search
432 echo "&passed_id=$passed_id&where=".urlencode($where).
433 "&what=".urlencode($what).'">';
435 echo "&passed_id=$passed_id&startMessage=$startMessage".
436 "&show_more=$show_more\">";
438 echo _("View message") . "</a></b></td></tr></table>\n".
439 "<table width='99%' cellpadding='2' cellspacing='0' border='0'".
444 for ($i=1; $i < count($read); $i++
) {
445 $line = htmlspecialchars($read[$i]);
446 if (eregi("^>", $line)) {
448 $first[$i] = ' ';
450 } else if (eregi("^[ |\t]", $line)) {
453 } else if (eregi("^([^:]+):(.+)", $line, $regs)) {
454 $first[$i] = $regs[1] . ':';
455 $second[$i] = $regs[2];
458 $second[$i] = trim($line);
462 for ($i=0; $i < count($second); $i = $j) {
463 if (isset($first[$i])) {
466 if (isset($second[$i])) {
467 $s = nl2br($second[$i]);
470 while (($first[$j] == '') && ($j < count($first))) {
471 $s .= ' ' . nl2br($second[$j]);
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
);
585 * What do we reply to -- text only, if possible
587 $ent_num = findDisplayEntity($message);
589 /** TEXT STRINGS DEFINITIONS **/
590 $echo_more = _("more");
591 $echo_less = _("less");
593 if (!isset($show_more_cc)) {
594 $show_more_cc = FALSE;
597 if (!isset($show_more_bcc)) {
598 $show_more_bcc = FALSE;
601 /** FORMAT THE TO STRING **/
602 $to = formatRecipientString($message->header
->to
, "to");
603 $to_string = $to['str'];
604 $url_to_string = $to['url_str'];
607 /** FORMAT THE CC STRING **/
609 $cc = formatRecipientString($message->header
->cc
, "cc");
610 $cc_string = $cc['str'];
611 $url_cc_string = $cc['url_str'];
613 /** FORMAT THE BCC STRING **/
615 $bcc = formatRecipientString($message->header
->bcc
, "bcc");
616 $bcc_string = $bcc['str'];
617 $url_bcc_string = $bcc['url_str'];
619 if ($default_use_priority) {
620 $priority_level = substr($message->header
->priority
,0,1);
622 switch($priority_level) {
623 /* check for a higher then normal priority. */
626 $priority_string = _("High");
629 /* check for a lower then normal priority. */
632 $priority_string = _("Low");
635 /* check for a normal priority. */
638 $priority_level = '3';
639 $priority_string = _("Normal");
645 /** make sure everything will display in HTML format **/
646 $from_name = decodeHeader(htmlspecialchars($message->header
->from
));
647 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
649 $idents = getPref($data_dir, $username, 'identities');
650 if (!empty($idents) && $idents > 1) {
651 for ($i = 1; $i < $idents; $i++
) {
652 $enc_from_name = '"'.
653 encodeHeader(getPref($data_dir,
656 '" <' . getPref($data_dir, $username,
657 'email_address' . $i) . '>';
658 if (htmlspecialchars($enc_from_name) == $from_name) {
665 do_hook('read_body_top');
667 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' .
668 '<TR><TD BGCOLOR="' . $color[9] . '" WIDTH="100%">' .
669 '<TABLE WIDTH="100%" CELLSPACING="0" BORDER="0" CELLPADDING="3">' .
671 '<TD ALIGN="LEFT" WIDTH="33%">' .
673 '<A HREF="' . $base_uri . 'src/';
675 if ($where && $what) {
679 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
681 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
683 echo _("Message List") .
684 '</A> | ' .
685 '<A HREF="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
686 if ($where && $what) {
687 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
689 echo "sort=$sort&startMessage=$startMessage\">";
691 echo _("Delete") . '</A> ';
692 if (($mailbox == $draft_folder) && ($save_as_draft)) {
693 echo '| <A HREF="' . $base_uri .
694 "src/compose.php?mailbox=$mailbox&identity=$identity&send_to=$url_to_string&send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&subject=$url_subj&mailprio=$priority_level&draft_id=$passed_id&ent_num=$ent_num" . '"';
695 if ($compose_new_win == '1') {
696 echo ' TARGET="compose_window" onClick="comp_in_new()"';
699 _("Resume Draft") . '</a>';
701 if ($mailbox == $sent_folder) {
702 echo '| <A HREF="' . $base_uri .
703 "src/compose.php?mailbox=$mailbox&identity=$identity&send_to=$url_to_string&send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&subject=$url_subj&mailprio=$priority_level&ent_num=$ent_num" . '"';
704 if ($compose_new_win == '1') {
705 echo ' TARGET="compose_window" onClick="comp_in_new()"';
708 _("Edit Message as New") . '</a>';
711 echo ' ' .
714 '<TD WIDTH="33%" ALIGN="CENTER">' .
717 if ( !($where && $what) ) {
718 if ($currentArrayIndex == -1) {
719 echo 'Previous | Next';
721 $prev = findPreviousMessage();
722 $next = findNextMessage();
725 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</A> | ";
727 echo _("Previous") . ' | ';
731 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</A>";
739 '</TD><TD WIDTH="33%" ALIGN="RIGHT">' .
741 '<A HREF="' . $base_uri . "src/compose.php?forward_id=$passed_id&forward_subj=$url_subj&".
742 ($default_use_priority?
"mailprio=$priority_level&":'')
743 ."mailbox=$urlMailbox&ent_num=$ent_num\"";
744 if ($compose_new_win == '1') {
745 echo 'TARGET="compose_window" onClick="comp_in_new()"';
749 '</A> | ' .
750 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replyto&reply_subj=$url_subj&".
751 ($default_use_priority?
"mailprio=$priority_level&":'').
752 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
753 if ($compose_new_win == '1') {
754 echo 'TARGET="compose_window" onClick="comp_in_new()"';
758 '</A> | ' .
759 '<A HREF="' . $base_uri . "src/compose.php?send_to=$url_replytoall&send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
760 ($default_use_priority?
"mailprio=$priority_level&":'').
761 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num\"";
762 if ($compose_new_win == '1') {
763 echo 'TARGET="compose_window" onClick="comp_in_new()"';
773 '<TR><TD WIDTH="100%">' .
774 '<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="3">' . "\n" .
778 echo "<TD BGCOLOR=\"$color[0]\" WIDTH=\"10%\" ALIGN=\"right\" VALIGN=\"top\">\n" .
780 "</TD><TD BGCOLOR=\"$color[0]\" WIDTH=\"80%\" VALIGN=\"top\">\n" .
781 "<B>$subject</B> \n" .
783 '<TD ROWSPAN="4" width="10%" BGCOLOR="' . $color[0] .
784 '" ALIGN=right VALIGN=top NOWRAP><small>'.
785 '<A HREF="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
787 /* From a search... */
788 if ($where && $what) {
789 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
790 "&view_hdr=1\">" . _("View Full Header") . "</A>\n";
792 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
793 _("View Full Header") . "</A>\n";
796 /* Output the printer friendly link if we are in subtle mode. */
797 if ($pf_subtle_link) {
798 echo printer_friendly_link(true);
801 do_hook("read_body_header_right");
802 echo '</small></TD>' .
807 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' .
809 '</TD><TD BGCOLOR="' . $color[0] . '">' .
810 "<B>$from_name</B> \n" .
815 '<TD BGCOLOR="' . $color[0] . '" ALIGN="RIGHT">' . "\n" .
817 "</TD><TD BGCOLOR=\"$color[0]\">\n" .
818 "<B>$dateString</B> \n" .
824 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>\n" .
826 '</TD><TD BGCOLOR="' . $color[0] . '" VALIGN="TOP">' . "\n" .
827 "<B>$to_string</B> \n" .
831 if (isset($cc_string) && $cc_string <> '') {
833 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
835 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
836 "<B>$cc_string</B> " .
842 if (isset($bcc_string) && $bcc_string <> '') {
844 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
846 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
847 "<B>$bcc_string</B> " .
851 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
853 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
854 _("Priority") . ': '.
855 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
856 "<B>$priority_string</B> " .
861 if ($show_xmailer_default) {
862 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (X-Mailer User-Agent)]", true,
863 $response, $readmessage);
864 $mailer = substr($read[1], strpos($read[1], " "));
867 "<TD BGCOLOR=\"$color[0]\" ALIGN=RIGHT VALIGN=TOP>" .
869 "</TD><TD BGCOLOR=\"$color[0]\" VALIGN=TOP colspan=2>" .
870 "<B>$mailer</B> " .
876 /* Output the printer friendly link if we are not in subtle mode. */
877 if (!$pf_subtle_link) {
878 echo printer_friendly_link(true);
881 if ($default_use_mdn) {
882 if ($mdn_user_support) {
884 // debug gives you the capability to remove mdn-flags
885 // $MDNDebug = false;
886 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY.PEEK[HEADER.FIELDS (Disposition-Notification-To)]", true,
887 $response, $readmessage);
888 $MDN_to = substr($read[1], strpos($read[1], ' '));
889 $MDN_flag_present = false;
891 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id FLAGS", true,
892 $response, $readmessage);
894 $MDN_flag_present = preg_match( '/.*\$MDNSent/i', $read[0]);
897 (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
899 if ( $MDN_flag_present && $supportMDN) {
900 $sendreceipt = 'removeMDN';
901 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
906 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
907 _("Read receipt") . ': ' .
908 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
911 "</B> <a href=$url>[" . _("Remove MDN flag") . '] </a>' .
917 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
918 _("Read receipt") . ': ' .
919 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
920 '<B>'._("send").'</B>'.
927 } // when deleted or draft flag is set don't offer to send a MDN response
928 else if ( ereg('\\Draft',$read[0] ||
ereg('\\Deleted',$read[0])) ) {
930 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
931 _("Read receipt") . ': '.
932 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
933 '<B>' . _("requested") . "</B>" .
937 // if no MDNsupport don't use the annoying popup messages
938 else if ( !$FirstTimeSee ) {
939 $sendreceipt = 'send';
940 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
942 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
943 _("Read receipt") . ': ' .
944 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
945 '<B>' . _("requested") .
946 "</B> <a href=\"$url\">[" . _("Send read receipt now") . "]</a>" .
952 $sendreceipt = 'send';
953 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
954 if ($javascript_on) {
955 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
957 " if (window.confirm(\"" .
958 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
960 " window.location=($url); \n" .
961 ' window.location.reload()' . "\n" .
967 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
968 _("Read receipt") . ': ' .
969 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
970 '<B>' . _("requested") . "  </B><a href=$url>" . '[' .
971 _("Send read receipt now") . '] </a>' ." \n" .
978 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
979 } else if ( $sendreceipt == 'send' ) {
980 if ( !$MDN_flag_present) {
981 if (isset($identity) ) {
982 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
984 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
987 $final_recipient = trim($final_recipient);
988 if ($final_recipient == '' ) {
989 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
992 if ( SendMDN( $MDN_to, $final_recipient ) > 0 && $supportMDN ) {
993 ToggleMDNflag( true);
996 $sendreceipt = 'removeMDN';
997 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1000 if ($MDNDebug && $supportMDN) {
1002 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
1003 " "._("Read receipt").": \n".
1004 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
1005 ' <B>'._("send").'</B>'." <a href=$url>" . '[' . _("Remove MDN flag") . '] </a>' . "\n" .
1011 " <TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>\n" .
1012 " "._("Read receipt").": \n".
1013 " </TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>\n" .
1014 ' <B>'._("send").'</B>'. "\n" .
1021 elseif ($sendreceipt == 'removeMDN' ) {
1022 ToggleMDNflag ( false );
1024 $sendreceipt = 'send';
1025 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1027 "<TD BGCOLOR=\"$color[9]\" ALIGN=RIGHT VALIGN=TOP>" .
1028 _("Read receipt") . ': ' .
1029 "</TD><TD BGCOLOR=\"$color[9]\" VALIGN=TOP colspan=2>" .
1030 '<B>' . _("requested") .
1031 "</B> <a href=$url>[" . _("Send read receipt now") . "]</a>" .
1040 do_hook('read_body_header');
1047 echo "<TABLE CELLSPACING=0 WIDTH=\"97%\" BORDER=0 ALIGN=CENTER CELLPADDING=0>\n" .
1048 " <TR><TD BGCOLOR=\"$color[4]\" WIDTH=\"100%\">\n" .
1050 formatBody($imapConnection, $message, $color, $wrap_at).
1051 '</TD></TR></TABLE>' .
1052 '<TABLE CELLSPACING="0" WIDTH="100%" BORDER="0" ALIGN="CENTER" CELLPADDING="0">' . "\n" .
1053 " <TR><TD BGCOLOR=\"$color[9]\"> </TD></TR>" .
1056 /* show attached images inline -- if pref'fed so */
1057 if (($attachment_common_show_images) &&
1058 is_array($attachment_common_show_images_list)) {
1060 foreach ($attachment_common_show_images_list as $img) {
1061 $imgurl = '../src/download.php' .
1063 'passed_id=' . urlencode($img['passed_id']) .
1064 '&mailbox=' . urlencode($mailbox) .
1065 '&passed_ent_id=' . urlencode($img['ent_id']) .
1066 '&absolute_dl=true';
1068 echo "<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER>\n" .
1071 "<img src=\"$imgurl\">\n" .
1080 do_hook('read_body_bottom');
1081 do_hook('html_bottom');
1082 sqimap_logout($imapConnection);