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');
21 require_once('../functions/html.php');
22 require_once('../src/view_header.php');
25 * Given an IMAP message id number, this will look it up in the cached
26 * and sorted msgs array and return the index. Used for finding the next
27 * and previous messages.
29 * @return the index of the next valid message from the array
31 function findNextMessage() {
32 global $msort, $currentArrayIndex, $msgs, $sort,
33 $thread_sort_messages, $allow_server_sort,
35 if (!is_array($server_sort_array)) {
36 $thread_sort_messages = 0;
37 $allow_server_sort = FALSE;
40 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
41 reset($server_sort_array);
42 while(list($key, $value) = each ($server_sort_array)) {
43 if ($currentArrayIndex == $value) {
44 if ($key == (count($server_sort_array) - 1)) {
48 $result = $server_sort_array[$key +
1];
53 elseif ($sort == 6 && $allow_server_sort != TRUE &&
54 $thread_sort_messages != 1) {
55 if ($currentArrayIndex != 1) {
56 $result = $currentArrayIndex - 1;
59 elseif ($allow_server_sort != TRUE && $thread_sort_messages != 1 ) {
60 if (!is_array($msort)) {
63 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
64 if ($currentArrayIndex == $msgs[$key]['ID']) {
68 $result = $msgs[$key]['ID'];
78 * Removes just one address from the list of addresses.
80 * @param &$addr_list a by-ref array of addresses
81 * @param $addr an address to remove
82 * @return void, since it operates on a by-ref param
84 function RemoveAddress(&$addr_list, $addr) {
86 foreach (array_keys($addr_list, $addr) as $key_to_delete) {
87 unset($addr_list[$key_to_delete]);
92 /** returns the index of the previous message from the array. */
93 function findPreviousMessage() {
94 global $msort, $currentArrayIndex, $sort, $msgs, $imapConnection,
95 $mailbox, $data_dir, $username, $thread_sort_messages,
96 $allow_server_sort, $server_sort_array;
98 if (!is_array($server_sort_array)) {
99 $thread_sort_messages = 0;
100 $allow_server_sort = FALSE;
102 if ($thread_sort_messages == 1 ||
$allow_server_sort == TRUE) {
103 reset($server_sort_array);
104 while(list($key, $value) = each ($server_sort_array)) {
105 if ($currentArrayIndex == $value) {
110 $result = $server_sort_array[$key -1];
115 elseif ($sort == 6 && $allow_server_sort != TRUE &&
116 $thread_sort_messages != 1) {
117 $numMessages = sqimap_get_num_messages($imapConnection, $mailbox);
118 if ($currentArrayIndex != $numMessages) {
119 $result = $currentArrayIndex +
1;
122 elseif ($thread_sort_messages != 1 && $allow_server_sort != TRUE) {
123 if (!is_array($msort)) {
126 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
127 if ($currentArrayIndex == $msgs[$key]['ID']) {
131 $result = $msgs[$key]['ID'];
141 * Displays a link to a page where the message is displayed more
142 * "printer friendly".
144 function printer_friendly_link() {
145 global $passed_id, $mailbox, $ent_num, $color,
149 if (strlen(trim($mailbox)) < 1) {
153 $params = '?passed_ent_id=' . $ent_num .
154 '&mailbox=' . urlencode($mailbox) .
155 '&passed_id=' . $passed_id;
157 $print_text = _("View Printable Version");
159 if (!$pf_subtle_link) {
160 /* The link is large, on the bottom of the header panel. */
161 $result = html_tag( 'tr', '', '', $color[0] ) .
162 html_tag( 'td', ' ', 'right', '', 'class="medText" valign="top"' ) .
163 html_tag( 'td', '', 'left', '', 'class="medText" valign="top" colspan="2"' ) . "\n";
165 /* The link is subtle, below "view full header". */
169 /* Output the link. */
170 if ($javascript_on) {
171 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
173 " function printFormat() {\n" .
174 ' window.open("../src/printer_friendly_main.php' .
175 $params . '","Print","width=800,height=600");' . "\n".
179 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
181 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
182 "$params\">$print_text</a>\n";
185 if (!$pf_subtle_link) {
186 /* The link is large, on the bottom of the header panel. */
187 $result .= '</td></tr>' . "\n";
193 function ServerMDNSupport( $read ) {
194 /* escaping $ doesn't work -> \x36 */
195 $ret = preg_match( '/(\x36MDNSent|\\\*)/i', $read );
199 function SendMDN ( $recipient , $sender) {
200 global $imapConnection, $mailbox, $username, $attachment_dir, $SERVER_NAME,
201 $version, $attachments, $identity, $data_dir, $passed_id;
203 $header = sqimap_get_message_header($imapConnection, $passed_id, $mailbox);
204 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
208 $senton = getLongDateString( $header->date
);
209 $to_array = $header->to
;
211 foreach ($to_array as $line) {
215 $subject = $header->subject
;
216 $now = getLongDateString( time() );
220 $body = _("Your message") . "\r\n\r\n" .
221 "\t" . _("To:") . ' ' . $to . "\r\n" .
222 "\t" . _("Subject:") . ' ' . $subject . "\r\n" .
223 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
225 sprintf( _("Was displayed on %s"), $now );
229 $original_recipient = $to;
230 $original_message_id = $header->message_id
;
232 $part2 = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
233 if ($original_recipient != '') {
234 $part2 .= "Original-Recipient : $original_recipient\r\n";
236 $final_recipient = $sender;
237 $part2 .= "Final-Recipient: rfc822; $final_recipient\r\n" .
238 "Original-Message-ID : $original_message_id\r\n" .
239 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
242 $localfilename = GenerateRandomString(32, 'FILE', 7);
243 $full_localfilename = "$hashed_attachment_dir/$localfilename";
245 $fp = fopen( $full_localfilename, 'w');
246 fwrite ($fp, $part2);
249 $newAttachment = array();
250 $newAttachment['localfilename'] = $localfilename;
251 $newAttachment['type'] = "message/disposition-notification";
252 $newAttachment['session']=-1;
253 $attachments[] = $newAttachment;
254 $MDN_to = trim($recipient);
257 return (SendMessage($MDN_to, '', '', _("Read:") . ' ' . $subject,
258 $body, $reply_id, True, 3, -1) );
262 function ToggleMDNflag ( $set ) {
263 global $imapConnection, $passed_id, $mailbox, $uid;
264 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, $passed_ent_id,
297 if ((is_array($recipients)) && (isset($recipients[0]))) {
305 $url = set_url_var($PHP_SELF, 'show_more',0);
307 $url = set_url_var($PHP_SELF, 'show_more',1);
309 } else if ($item == 'cc') {
311 $url = set_url_var($PHP_SELF, 'show_more_cc',0);
314 $url = set_url_var($PHP_SELF, 'show_more_cc',1);
316 } else if ($item == 'bcc') {
317 if ($show_more_bcc) {
318 $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
321 $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
328 $ary[$i] = $addr_o->getAddress();
329 $ary[$i] = decodeHeader(htmlspecialchars($ary[$i]));
330 $url_string .= $ary[$i];
332 $string .= '<BR>'.$ary[$i];
336 $string .= ' (<A HREF="'.$url;
338 $string .= '">'.$echo_less.'</A>)';
340 $string .= '">'.$echo_more.'</A>)';
351 $url_string = urlencode($url_string);
353 $result['str'] = $string;
354 $result['url_str'] = $url_string;
361 * Main of read_boby.php --------------------------------------------------
370 global $uid_support, $sqimap_capabilities;
372 if (isset($mailbox)){
373 $mailbox = urldecode( $mailbox );
376 $imapConnection = sqimap_login($username, $key, $imapServerAddress,
379 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
381 if (!isset($messages)) {
383 session_register('messages');
387 * $message contains all information about the message
388 * including header and body
391 $uidvalidity = $mbx_response['UIDVALIDITY'];
393 if (!isset($messages[$uidvalidity])) {
394 $messages[$uidvalidity] = array();
396 if (!isset($messages[$uidvalidity][$passed_id])) {
397 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
398 $messages[$uidvalidity][$passed_id] = $message;
399 $header = $message->header
;
401 $message = $messages[$uidvalidity][$passed_id];
402 // $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
403 if (isset($passed_ent_id)) {
404 $message = $message->getEntity($passed_ent_id);
405 $message->id
= $passed_id;
406 $message->mailbox
= $mailbox;
408 $header = $message->header
;
414 * The following code sets necesarry stuff for the MDN thing
416 if($default_use_mdn &&
417 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
418 $default_use_mdn))) {
419 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
420 $FirstTimeSee = !$message->is_seen
;
423 displayPageHeader($color, $mailbox);
426 * The following code shows the header of the message and then exit
428 if (isset($view_hdr)) {
429 $template_vars = array();
430 parse_viewheader($imapConnection,$passed_id,&$template_vars);
431 $template_vars['return_address'] = set_url_var($PHP_SELF, 'view_hdr');
432 view_header($template_vars, '', '</body></html>');
437 $currentArrayIndex = $passed_id;
439 $currentArrayIndex = -1;
441 $msgs[$passed_id]['FLAG_SEEN'] = true;
445 * The following code sets necesarry stuff for the MDN thing
447 if($default_use_mdn &&
448 ($mdn_user_support = getPref($data_dir, $username, 'mdn_user_support',
449 $default_use_mdn))) {
450 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
451 $FirstTimeSee = !$message->is_seen
;
455 * The following code shows the header of the message and then exit
457 if (isset($view_hdr)) {
458 $template_vars = array();
459 parse_viewheader($imapConnection,$passed_id,&$template_vars);
460 $template_vars['return_address'] = set_url_var($PHP_SELF, 'view_hdr');
461 view_header($template_vars, '', '</body></html>');
466 $currentArrayIndex = $passed_id;
468 $currentArrayIndex = -1;
470 $msgs[$passed_id]['FLAG_SEEN'] = true;
472 /** translate the subject and mailbox into url-able text **/
473 $url_subj = urlencode(trim($header->subject
));
474 $urlMailbox = urlencode($mailbox);
476 if (isset($header->replyto
)) {
477 $addr_o = $header->replyto
;
478 $addr_s = $addr_o->getAddress();
479 $url_replyto = urlencode($addr_s);
482 $url_replytoall = $url_replyto;
485 * If we are replying to all, then find all other addresses and
486 * add them to the list. Remove duplicates.
492 * 1) Remove the addresses we'll be sending the message 'to'
494 $url_replytoall_avoid_addrs = '';
495 if (isset($header->replyto
)) {
496 $excl_ar = $header->getAddr_a('replyto');
501 * 2) Remove our identities from the CC list (they still can be in the
502 * TO list) only if $include_self_reply_all is turned off
504 if (!$include_self_reply_all) {
505 $email_address = trim(getPref($data_dir, $username, 'email_address'));
506 $excl_ar[$email_address] = '';
508 $idents = getPref($data_dir, $username, 'identities');
509 if ($idents != '' && $idents > 1) {
510 for ($i = 1; $i < $idents; $i ++
) {
511 $cur_email_address = getPref($data_dir, $username,
512 'email_address' . $i);
513 $cur_email_address = strtolower($cur_email_address);
514 $excl_ar[$cur_email_address] = '';
520 * 3) get the addresses.
522 $url_replytoall_ar = $header->getAddr_a(array('from','to','cc'), $excl_ar);
525 * 4) generate the string.
527 $url_replytoallcc = '';
528 foreach( $url_replytoall_ar as $email => $personal) {
530 $url_replytoallcc .= ", \"$personal\" <$email>";
532 $url_replytoallcc .= ', '. $email;
535 $url_replytoallcc = substr($url_replytoallcc,2);
540 $url_replytoallcc = urlencode($url_replytoallcc);
542 $dateString = getLongDateString($header->date
);
545 * What do we reply to -- text only, if possible
550 /* first step in displaying multiple entities */
552 $ent_ar = findDisplayEntity($message, false);
554 for ($i = 0; $i < count($ent_ar); $i++
) {
555 $body .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i]);
559 $ent_ar = findDisplayEntity($message,true);
561 $ent_num = $ent_ar[0];
562 for ($i = 1 ; $i < count($ent_ar); $i++
) {
563 $ent_num .= '_'.$ent_ar[$i];
565 /** TEXT STRINGS DEFINITIONS **/
566 $echo_more = _("more");
567 $echo_less = _("less");
569 if (!isset($show_more_cc)) {
570 $show_more_cc = FALSE;
573 if (!isset($show_more_bcc)) {
574 $show_more_bcc = FALSE;
577 /** FORMAT THE TO STRING **/
578 $to = formatRecipientString($message->header
->to
, "to");
579 $to_string = $to['str'];
580 $url_to_string = $to['url_str'];
583 /** FORMAT THE CC STRING **/
585 $cc = formatRecipientString($header->cc
, "cc");
586 $cc_string = $cc['str'];
587 $url_cc_string = $cc['url_str'];
589 /** FORMAT THE BCC STRING **/
591 $bcc = formatRecipientString($header->bcc
, "bcc");
592 $bcc_string = $bcc['str'];
593 $url_bcc_string = $bcc['url_str'];
595 if ($default_use_priority) {
596 $priority_level = substr($header->priority
,0,1);
598 switch($priority_level) {
599 /* check for a higher then normal priority. */
602 $priority_string = _("High");
605 /* check for a lower then normal priority. */
608 $priority_string = _("Low");
611 /* check for a normal priority. */
614 $priority_level = '3';
615 $priority_string = _("Normal");
621 /** make sure everything will display in HTML format **/
623 $from_o = $header->from
;
624 if (is_object($from_o)) {
625 $from_name = $from_o->getAddress();
627 $from_name = _("Unknown sender");
629 $from_name = decodeHeader(htmlspecialchars($from_name));
630 $subject = decodeHeader(htmlspecialchars($message->header
->subject
));
632 $idents = getPref($data_dir, $username, 'identities');
633 if (!empty($idents) && $idents > 1) {
634 for ($i = 1; $i < $idents; $i++
) {
635 $enc_from_name = '"'.
636 encodeHeader(getPref($data_dir,
639 '" <' . getPref($data_dir, $username,
640 'email_address' . $i) . '>';
641 if (htmlspecialchars($enc_from_name) == $from_name) {
648 do_hook('read_body_top');
651 html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="0" cellspacing="0" border="0"' ) . "\n" .
653 html_tag( 'td', '', 'left', $color[9], 'width="100%"' ) .
654 html_tag( 'table', '', '', '', 'width="100%" cellpadding="3" cellspacing="0" border="0"' ) . "\n" .
656 html_tag( 'td', '', 'left', '', 'width="33%"' ) .
658 '<a href="' . $base_uri . 'src/';
660 if ($where && $what) {
664 echo "search.php?where=".urlencode($where)."&pos=$pos&what=".urlencode($what)."&mailbox=$urlMailbox\">";
666 echo "right_main.php?sort=$sort&startMessage=$startMessage&mailbox=$urlMailbox\">";
668 echo _("Message List") .
669 '</a> | ' .
670 '<a href="' . $base_uri . "src/delete_message.php?mailbox=$urlMailbox&message=$passed_id&";
671 if ($where && $what) {
672 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) . '">';
674 echo "sort=$sort&startMessage=$startMessage\">";
676 echo _("Delete") . '</a> ';
677 if (($mailbox == $draft_folder) && ($save_as_draft)) {
678 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
679 "identity=$identity&send_to=$url_to_string&".
680 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
681 "subject=$url_subj&mailprio=$priority_level&".
682 "draft_id=$passed_id&ent_num=$ent_num";
684 if ($compose_new_win == '1') {
685 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
687 echo '| <a href="' . $comp_uri .'"';
690 _("Resume Draft") . '</a>';
692 if ($mailbox == $sent_folder) {
693 $comp_uri = $base_uri . "src/compose.php?mailbox=$mailbox&".
694 "identity=$identity&send_to=$url_to_string&".
695 "send_to_cc=$url_cc_string&send_to_bcc=$url_bcc_string&".
696 "subject=$url_subj&mailprio=$priority_level&".
697 "ent_num=$ent_num&passed_id=$passed_id&edit_as_new=1";
699 if ($compose_new_win == '1') {
700 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
702 echo '| <a href="' . $comp_uri .'"';
705 _("Edit Message as New") . '</a>';
708 echo ' ' .
711 html_tag( 'td', '', 'center', '', 'width="33%"' ) .
714 if ( !($where && $what) ) {
715 if ($currentArrayIndex == -1) {
716 echo 'Previous | Next';
718 $prev = findPreviousMessage($mbx_response['EXISTS']);
719 $next = findNextMessage();
722 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$prev&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Previous") . "</a> | ";
724 echo _("Previous") . ' | ';
728 echo '<a href="' . $base_uri . "src/read_body.php?passed_id=$next&mailbox=$urlMailbox&sort=$sort&startMessage=$startMessage&show_more=0\">" . _("Next") . "</a>";
737 html_tag( 'td', '', 'right', '', 'width="33%"' ) .
739 $comp_uri = $base_uri . "src/compose.php?forward_id=$passed_id&".
740 "forward_subj=$url_subj&".
741 ($default_use_priority?
"mailprio=$priority_level&":'').
742 "mailbox=$urlMailbox&ent_num=$ent_num";
744 if ($compose_new_win == '1') {
745 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
747 echo '| <a href="' . $comp_uri .'"';
754 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replyto&".
755 "reply_subj=$url_subj&".
756 ($default_use_priority?
"mailprio=$priority_level&":'').
757 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
759 if ($compose_new_win == '1') {
760 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
762 echo '| <a href="' . $comp_uri .'"';
769 $comp_uri = $base_uri . "src/compose.php?send_to=$url_replytoall&".
770 "send_to_cc=$url_replytoallcc&reply_subj=$url_subj&".
771 ($default_use_priority?
"mailprio=$priority_level&":'').
772 "reply_id=$passed_id&mailbox=$urlMailbox&ent_num=$ent_num";
774 if ($compose_new_win == '1') {
775 echo "<a href=\"javascript:void(0)\" onclick=\"comp_in_new(false,'$comp_uri')\"";
777 echo '| <a href="' . $comp_uri .'"';
789 html_tag( 'td', '', 'left', '', 'width="100%"' ) .
790 html_tag( 'table', '', '', '', 'width="100%" border="0" cellspacing="0" cellpadding="3"' ) .
791 html_tag( 'tr' ) . "\n";
794 echo html_tag( 'td', _("Subject:"), 'right', $color[0], 'width="10%" valign="top"' ) .
795 html_tag( 'td', '<b>' . $subject . '</b> ' . "\n", 'left', $color[0], 'width="80%" valign="top"' ) .
796 html_tag( 'td', '', 'right', $color[0], 'rowspan="4" width="10%" valign="top" nowrap' ) .
797 '<a href="' . $base_uri . "src/read_body.php?mailbox=$urlMailbox&passed_id=$passed_id&";
799 /* From a search... */
800 if ($where && $what) {
801 echo 'where=' . urlencode($where) . '&what=' . urlencode($what) .
802 "&view_hdr=1\">" . _("View Full Header") . "</a>\n";
804 echo "startMessage=$startMessage&show_more=$show_more&view_hdr=1\">" .
805 _("View Full Header") . "</a>\n";
808 /* Output the printer friendly link if we are in subtle mode. */
809 if ($pf_subtle_link) {
810 echo printer_friendly_link(true);
813 do_hook("read_body_header_right");
814 echo '</small></td>' .
818 echo html_tag( 'tr', "\n" .
819 html_tag( 'td', _("From:"), 'right', $color[0], 'valign="top"' ) .
821 '<b>' . $from_name . '</b> ' . "\n" ,
824 do_hook("read_body_after_from");
826 echo html_tag( 'tr', "\n" .
827 html_tag( 'td', _("Date:"), 'right', $color[0], 'valign="top"' ) .
829 '<b>' . $dateString . '</b> ' . "\n" ,
833 echo html_tag( 'tr', "\n" .
834 html_tag( 'td', _("To:"), 'right', $color[0], 'valign="top"' ) .
836 '<b>' . $to_string . '</b> ' . "\n" ,
840 if (isset($cc_string) && $cc_string <> '') {
841 echo html_tag( 'tr', "\n" .
842 html_tag( 'td', _("Cc:"), 'right', $color[0], 'valign="top"' ) .
844 '<b>' . $cc_string . '</b> ' . "\n" ,
845 'left', $color[0], 'colspan="2" valign="top"' )
850 if (isset($bcc_string) && $bcc_string <> '') {
851 echo html_tag( 'tr', "\n" .
852 html_tag( 'td', _("Bcc:"), 'right', $color[0], 'valign="top"' ) .
854 '<b>' . $bcc_string . '</b> ' . "\n" ,
855 'left', $color[0], 'colspan="2" valign="top"' )
858 if ($default_use_priority && isset($priority_string) && $priority_string <> '' ) {
859 echo html_tag( 'tr', "\n" .
860 html_tag( 'td', _("Priority") . ':', 'right', $color[0], 'valign="top"' ) .
862 '<b>' . $priority_string . '</b> ' . "\n" ,
863 'left', $color[0], 'colspan="2" valign="top"' )
867 if ($show_xmailer_default) {
868 $mailer = $header->xmailer
;
870 echo html_tag( 'tr', "\n" .
871 html_tag( 'td', _("Mailer") . ':', 'right', $color[0], 'valign="top"' ) .
873 '<b>' . $mailer . '</b> ' ,
874 'left', $color[0], 'colspan="2" valign="top"' )
879 /* Output the printer friendly link if we are not in subtle mode. */
880 if (!$pf_subtle_link) {
881 echo printer_friendly_link(true);
884 if ($default_use_mdn) {
885 if ($mdn_user_support) {
887 // debug gives you the capability to remove mdn-flags
888 // $MDNDebug = false;
891 $MDN_to_o = $header->dnt
;
892 $MDN_to = $MDN_to_o->getAddress();
897 if ($MDN_to && (!isset( $sendreceipt ) ||
$sendreceipt == '' ) ) {
898 if ( $message->is_mdnsent
&& $supportMDN) {
899 $sendreceipt = 'removeMDN';
901 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
905 echo html_tag( 'tr', "\n" .
906 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
908 '<b>' . _("send") . '</b> <a href="' . $url . '">[' . _("Remove MDN flag") . '] </a> ' ,
909 'left', $color[9], 'colspan="2" valign="top"' )
913 echo html_tag( 'tr', "\n" .
914 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
916 '<b>' . _("send") . '</b> ' ,
917 'left', $color[9], 'colspan="2" valign="top"' )
923 } // when deleted or draft flag is set don't offer to send a MDN response
924 else if ( $message->is_draft ||
$message->is_deleted
) {
925 echo html_tag( 'tr', "\n" .
926 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
928 '<b>' . _("requested") . '</b> ' ,
929 'left', $color[9], 'colspan="2" valign="top"' )
932 // if no MDNsupport don't use the annoying popup messages
933 else if ( !$FirstTimeSee ) {
934 $sendreceipt = 'send';
935 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
936 echo html_tag( 'tr', "\n" .
937 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
939 '<b>' . _("requested") . '</b> <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
940 'left', $color[9], 'colspan="2" valign="top"' )
945 $sendreceipt = 'send';
946 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
947 if ($javascript_on) {
948 echo "<script language=\"javascript\" type=\"text/javascript\"> \n" .
950 " if (window.confirm(\"" .
951 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
953 ' window.open('.$url.',"right");' . "\n" .
958 echo html_tag( 'tr', "\n" .
959 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
961 '<b>' . _("requested") . '</b>  <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
962 'left', $color[9], 'colspan="2" valign="top"' )
968 if ( !isset( $sendreceipt ) ||
$sendreceipt == '' ) {
969 } else if ( $sendreceipt == 'send' ) {
970 if ( !$MDN_flag_present) {
971 if (isset($identity) ) {
972 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
974 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
978 $final_recipient = trim($final_recipient);
979 if ($final_recipient == '' ) {
980 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
983 if ( SendMDN( $MDN_to, $final_recipient, $message ) > 0 && $supportMDN ) {
984 ToggleMDNflag( true);
988 $sendreceipt = 'removeMDN';
989 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
992 if ($MDNDebug && $supportMDN) {
993 echo html_tag( 'tr', "\n" .
994 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
996 '<b>' . _("send") . '</b>  <a href="' . $url . '">[' . _("Remove MDN flag") . ']</a>',
997 'left', $color[9], 'colspan="2" valign="top"' )
1001 echo html_tag( 'tr', "\n" .
1002 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1004 '<b>' . _("send") . '</b> ',
1005 'left', $color[9], 'colspan="2" valign="top"' )
1011 elseif ($sendreceipt == 'removeMDN' ) {
1012 ToggleMDNflag ( false );
1014 $sendreceipt = 'send';
1015 $url = "\"read_body.php?mailbox=$mailbox&passed_id=$passed_id&startMessage=$startMessage&show_more=$show_more&sendreceipt=$sendreceipt\"";
1016 echo html_tag( 'tr', "\n" .
1017 html_tag( 'td', _("Read receipt") . ':', 'right', $color[9], 'valign="top"' ) .
1019 '<b>' . _("requested") . '</b> <a href="' . $url . '">[' . _("Send read receipt now") . ']</a>',
1020 'left', $color[9], 'colspan="2" valign="top"' )
1028 do_hook('read_body_header');
1034 echo html_tag( 'table', "\n" .
1035 html_tag( 'tr', "\n" .
1036 html_tag( 'td', '<br>' . "\n" . $body . "\n", 'left', $color[4]
1039 'center', '', 'cellspacing=0 width="97%" border="0" cellpadding="0"') .
1041 html_tag( 'table', "\n" .
1042 html_tag( 'tr', "\n" .
1043 html_tag( 'td', ' ', 'left', $color[9]
1046 'center', '', 'cellspacing=0 width="100%" border="0" cellpadding="0"');
1048 /* show attached images inline -- if pref'fed so */
1049 if (($attachment_common_show_images) &&
1050 is_array($attachment_common_show_images_list)) {
1052 foreach ($attachment_common_show_images_list as $img) {
1053 $imgurl = '../src/download.php' .
1055 'passed_id=' . urlencode($img['passed_id']) .
1056 '&mailbox=' . urlencode($mailbox) .
1057 '&passed_ent_id=' . urlencode($img['ent_id']) .
1058 '&absolute_dl=true';
1060 echo html_tag( 'table', "\n" .
1061 html_tag( 'tr', "\n" .
1062 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
1065 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
1070 do_hook('read_body_bottom');
1071 do_hook('html_bottom');
1072 sqimap_logout($imapConnection);