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 /* Path for SquirrelMail required files. */
16 define('SM_PATH','../');
18 /* SquirrelMail required files. */
19 require_once(SM_PATH
. 'include/validate.php');
20 require_once(SM_PATH
. 'functions/imap.php');
21 require_once(SM_PATH
. 'functions/mime.php');
22 require_once(SM_PATH
. 'functions/date.php');
23 require_once(SM_PATH
. 'functions/url_parser.php');
24 require_once(SM_PATH
. 'functions/html.php');
28 * Given an IMAP message id number, this will look it up in the cached
29 * and sorted msgs array and return the index. Used for finding the next
30 * and previous messages.
32 * @return the index of the next valid message from the array
34 function findNextMessage($passed_id) {
35 global $msort, $msgs, $sort,
36 $thread_sort_messages, $allow_server_sort,
38 if (!is_array($server_sort_array)) {
39 $thread_sort_messages = 0;
40 $allow_server_sort = FALSE;
43 if ($thread_sort_messages ||
$allow_server_sort) {
44 $count = count($server_sort_array) - 1;
45 foreach($server_sort_array as $key=>$value) {
46 if ($passed_id == $value) {
50 $result = $server_sort_array[$key +
1];
55 if (is_array($msort)) {
56 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
57 if ($passed_id == $msgs[$key]['ID']) {
61 $result = $msgs[$key]['ID'];
71 /** returns the index of the previous message from the array. */
72 function findPreviousMessage($numMessages, $passed_id) {
73 global $msort, $sort, $msgs,
74 $thread_sort_messages,
75 $allow_server_sort, $server_sort_array;
77 if (!is_array($server_sort_array)) {
78 $thread_sort_messages = 0;
79 $allow_server_sort = FALSE;
81 if ($thread_sort_messages ||
$allow_server_sort ) {
82 foreach($server_sort_array as $key=>$value) {
83 if ($passed_id == $value) {
87 $result = $server_sort_array[$key - 1];
92 if (is_array($msort)) {
93 for (reset($msort); ($key = key($msort)), (isset($key)); next($msort)) {
94 if ($passed_id == $msgs[$key]['ID']) {
98 $result = $msgs[$key]['ID'];
109 * Displays a link to a page where the message is displayed more
110 * "printer friendly".
112 function printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color) {
113 global $javascript_on;
115 $params = '?passed_ent_id=' . $passed_ent_id .
116 '&mailbox=' . urlencode($mailbox) .
117 '&passed_id=' . $passed_id;
119 $print_text = _("View Printable Version");
122 /* Output the link. */
123 if ($javascript_on) {
124 $result .= '<script language="javascript" type="text/javascript">' . "\n" .
126 " function printFormat() {\n" .
127 ' window.open("../src/printer_friendly_main.php' .
128 $params . '","Print","width=800,height=600");' . "\n".
132 "<a href=\"javascript:printFormat();\">$print_text</a>\n";
134 $result .= '<A target="_blank" HREF="../src/printer_friendly_bottom.php' .
135 "$params\">$print_text</a>\n";
140 function ServerMDNSupport($read) {
141 /* escaping $ doesn't work -> \x36 */
142 $ret = preg_match('/(\x36MDNSent|\\\*)/i', $read);
146 function SendMDN ( $mailbox, $passed_id, $sender, $message, $imapConnection) {
147 global $username, $attachment_dir, $_SERVER,
148 $version, $attachments, $squirrelmail_language, $default_charset,
149 $languages, $useSendmail, $domain, $sent_folder,
150 $popuser, $data_dir, $username;
152 $SERVER_NAME = $_SERVER['SERVER_NAME'];
154 $header = $message->rfc822_header
;
155 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
157 $rfc822_header = new Rfc822Header();
158 $content_type = new ContentType('multipart/report');
159 $content_type->properties
['report-type']='disposition-notification';
162 if ($default_charset) {
163 $content_type->properties
['charset']=$default_charset;
165 $rfc822_header->content_type
= $content_type;
166 $rfc822_header->to
[] = $header->dnt
;
167 $rfc822_header->subject
= _("Read:") . ' ' . $header->subject
;
171 if (isset($identity) && $identity != 'default') {
172 $from_mail = getPref($data_dir, $username,
173 'email_address' . $identity);
174 $full_name = getPref($data_dir, $username,
175 'full_name' . $identity);
176 $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
177 $reply_to = getPref($data_dir, $username,
178 'reply_to' . $identity);
180 $from_mail = getPref($data_dir, $username, 'email_address');
181 $full_name = getPref($data_dir, $username, 'full_name');
182 $from_addr = '"'.$full_name.'" <'.$from_mail.'>';
183 $reply_to = getPref($data_dir, $username,'reply_to');
186 $from_addr = "$popuser@$domain";
187 $from_mail = $from_addr;
189 $rfc822_header->from
= $rfc822_header->parseAddress($from_addr,true);
191 $rfc822_header->reply_to
= $rfc822_header->parseAddress($reply_to,true);
195 $senton = getLongDateString( $header->date
);
196 $to_array = $header->to
;
198 foreach ($to_array as $line) {
199 $to .= ' '.$line->getAddress();
201 $now = getLongDateString( time() );
203 $body = _("Your message") . "\r\n\r\n" .
204 "\t" . _("To:") . ' ' . $to . "\r\n" .
205 "\t" . _("Subject:") . ' ' . $header->subject
. "\r\n" .
206 "\t" . _("Sent:") . ' ' . $senton . "\r\n" .
208 sprintf( _("Was displayed on %s"), $now );
210 $special_encoding = '';
211 if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
212 function_exists($languages[$squirrelmail_language]['XTRA_CODE'])) {
213 $body = $languages[$squirrelmail_language]['XTRA_CODE']('encode', $body);
214 if (strtolower($default_charset) == 'iso-2022-jp') {
215 if (mb_detect_encoding($body) == 'ASCII') {
216 $special_encoding = '8bit';
218 $body = mb_convert_encoding($body, 'JIS');
219 $special_encoding = '7bit';
223 $part1 = new Message();
224 $part1->setBody($body);
225 $mime_header = new MessageHeader
;
226 $mime_header->type0
= 'text';
227 $mime_header->type1
= 'plain';
228 if ($special_encoding) {
229 $mime_header->encoding
= $special_encoding;
231 $mime_header->encoding
= 'us-ascii';
233 if ($default_charset) {
234 $mime_header->parameters
['charset'] = $default_charset;
236 $part1->mime_header
= $mime_header;
239 $original_recipient = $to;
240 $original_message_id = $header->message_id
;
242 $report = "Reporting-UA : $SERVER_NAME ; SquirrelMail (version $version) \r\n";
243 if ($original_recipient != '') {
244 $report .= "Original-Recipient : $original_recipient\r\n";
246 $final_recipient = $sender;
247 $report .= "Final-Recipient: rfc822; $final_recipient\r\n" .
248 "Original-Message-ID : $original_message_id\r\n" .
249 "Disposition: manual-action/MDN-sent-manually; displayed\r\n";
251 $part2 = new Message();
252 $part2->setBody($report);
253 $mime_header = new MessageHeader
;
254 $mime_header->type0
= 'message';
255 $mime_header->type1
= 'disposition-notification';
256 $mime_header->encoding
= 'us-ascii';
257 $part2->mime_header
= $mime_header;
259 $composeMessage = new Message();
260 $composeMessage->rfc822_header
= $rfc822_header;
261 $composeMessage->addEntity($part1);
262 $composeMessage->addEntity($part2);
266 require_once(SM_PATH
. 'class/deliver/Deliver_SendMail.class.php');
267 global $sendmail_path;
268 $deliver = new Deliver_SendMail();
269 $stream = $deliver->initStream($composeMessage,$sendmail_path);
271 require_once(SM_PATH
. 'class/deliver/Deliver_SMTP.class.php');
272 $deliver = new Deliver_SMTP();
273 global $smtpServerAddress, $smtpPort, $use_authenticated_smtp, $pop_before_smtp;
274 if ($use_authenticated_smtp) {
275 global $key, $onetimepad;
277 $pass = OneTimePadDecrypt($key, $onetimepad);
282 $authPop = (isset($pop_before_smtp) && $pop_before_smtp) ?
true : false;
283 $stream = $deliver->initStream($composeMessage,$domain,0,
284 $smtpServerAddress, $smtpPort, $authPop);
288 $length = $deliver->mail($composeMessage, $stream);
289 $success = $deliver->finalizeStream($stream);
292 $msg = $deliver->dlv_msg
. '<br>Server replied: '.$deliver->dlv_ret_nr
;
293 require_once(SM_PATH
. 'functions/display_messages.php');
294 plain_error_message($msg, $color);
297 if (sqimap_mailbox_exists ($imapConnection, $sent_folder)) {
298 sqimap_append ($imapConnection, $sent_folder, $length);
299 require_once(SM_PATH
. 'class/deliver/Deliver_IMAP.class.php');
300 $imap_deliver = new Deliver_IMAP();
301 $imap_deliver->mail($composeMessage, $imapConnection);
302 sqimap_append_done ($imapConnection);
303 unset ($imap_deliver);
310 function ToggleMDNflag ($set ,$imapConnection, $mailbox, $passed_id, $uid_support) {
312 $cmd = 'STORE ' . $passed_id . ' ' . $sg . 'FLAGS ($MDNSent)';
313 $read = sqimap_run_command ($imapConnection, $cmd, true, $response,
314 $readmessage, $uid_support);
317 function ClearAttachments() {
318 global $username, $attachments, $attachment_dir;
320 $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
322 $rem_attachments = array();
323 foreach ($attachments as $info) {
324 if ($info['session'] == -1) {
325 $attached_file = "$hashed_attachment_dir/$info[localfilename]";
326 if (file_exists($attached_file)) {
327 unlink($attached_file);
330 $rem_attachments[] = $info;
333 $attachments = $rem_attachments;
336 function formatRecipientString($recipients, $item ) {
337 global $show_more_cc, $show_more, $show_more_bcc,
341 if ((is_array($recipients)) && (isset($recipients[0]))) {
347 $url = set_url_var($PHP_SELF, 'show_more',0);
349 $url = set_url_var($PHP_SELF, 'show_more',1);
351 } else if ($item == 'cc') {
354 $url = set_url_var($PHP_SELF, 'show_more_cc',0);
356 $url = set_url_var($PHP_SELF, 'show_more_cc',1);
358 } else if ($item == 'bcc') {
359 if ($show_more_bcc) {
361 $url = set_url_var($PHP_SELF, 'show_more_bcc',0);
363 $url = set_url_var($PHP_SELF, 'show_more_bcc',1);
367 $cnt = count($recipients);
368 foreach($recipients as $r) {
369 $add = htmlspecialchars($r->getAddress());
371 $string .= '<BR>' . $add;
375 $string .= ' (<A HREF="'.$url;
377 $string .= '">'._("less").'</A>)';
379 $string .= '">'._("more").'</A>)';
389 function formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message,
390 $color, $FirstTimeSee) {
391 global $msn_user_support, $default_use_mdn, $draft_folder, $sent_folder,
392 $default_use_priority, $show_xmailer_default,
393 $mdn_user_support, $PHP_SELF, $javascript_on;
395 $header = $message->rfc822_header
;
397 $env[_("Subject")] = htmlspecialchars(decodeHeader($header->subject
));
398 $from_name = $header->getAddr_s('from');
400 $from_name = $header->getAddr_s('sender');
402 $from_name = _("Unknown sender");
405 $env[_("From")] = htmlspecialchars(decodeHeader($from_name));
406 $env[_("Date")] = getLongDateString($header->date
);
407 $env[_("To")] = formatRecipientString($header->to
, "to");
408 $env[_("Cc")] = formatRecipientString($header->cc
, "cc");
409 $env[_("Bcc")] = formatRecipientString($header->bcc
, "bcc");
410 if ($default_use_priority) {
411 $env[_("Priority")] = getPriorityStr($header->priority
);
413 if ($show_xmailer_default) {
414 $env[_("Mailer")] = decodeHeader($header->xmailer
);
416 if ($default_use_mdn) {
417 if ($mdn_user_support) {
419 if ($message->is_mdnsent
) {
420 $env[_("Read receipt")] = _("send");
422 $env[_("Read receipt")] = _("requested");
423 if (!($mailbox == $draft_folder ||
424 $mailbox == $sent_folder ||
425 $message->is_deleted ||
427 $mdn_url = $PHP_SELF . '&sendreceipt=1';
428 if ($FirstTimeSee && $javascript_on) {
429 $script = '<script language="JavaScript" type="text/javascript">' . "\n";
430 $script .= '<!--'. "\n";
431 $script .= 'if(window.confirm("' .
432 _("The message sender has requested a response to indicate that you have read this message. Would you like to send a receipt?") .
436 $script .= '// -->'. "\n";
437 $script .= '</script>'. "\n";
440 $env[_("Read receipt")] .= ' <a href="' . $mdn_url . '">[' .
441 _("Send read receipt now") . ']</a>';
448 $s = '<TABLE WIDTH="100%" CELLPADDING="0" CELLSPACING="2" BORDER="0"';
449 $s .= ' ALIGN="center" BGCOLOR="'.$color[0].'">';
450 foreach ($env as $key => $val) {
453 $s .= html_tag('TD', '<B>' . $key . ': </B>', 'RIGHT', '', 'VALIGN="TOP" WIDTH="20%"') . "\n";
454 $s .= html_tag('TD', $val, 'left', '', 'VALIGN="TOP" WIDTH="80%"') . "\n";
458 echo '<TABLE BGCOLOR="'.$color[9].'" WIDTH="100%" CELLPADDING="1"'.
459 ' CELLSPACING="0" BORDER="0" ALIIGN="center">'."\n";
460 echo '<TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.$color[4].'"></TD></TR><TR><TD
463 do_hook("read_body_header");
464 formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color);
466 echo '</TD></TR><TR><TD HEIGHT="5" COLSPAN="2" BGCOLOR="'.$color[4].'"></TD></TR>'."\n";
470 function formatMenubar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response) {
471 global $base_uri, $sent_folder, $draft_folder, $where, $what, $color, $sort,
472 $startMessage, $compose_new_win, $PHP_SELF, $save_as_draft,
473 $enable_forward_as_attachment;
475 $topbar_delimiter = ' | ';
476 $urlMailbox = urlencode($mailbox);
477 $s = '<table width="100%" cellpadding="3" cellspacing="0" align="center"'.
478 ' border="0" bgcolor="'.$color[9].'"><tr><td align="left" width="33%"><small>';
480 $msgs_url = $base_uri . 'src/';
481 if (isset($where) && isset($what)) {
482 $msgs_url .= 'search.php?where=' . urlencode($where) .
483 '&what=' . urlencode($what) . '&mailbox=' . $urlMailbox;
484 $msgs_str = _("Search results");
486 $msgs_url .= 'right_main.php?sort=' . $sort . '&startMessage=' .
487 $startMessage . '&mailbox=' . $urlMailbox;
488 $msgs_str = _("Message List");
490 $s .= '<a href="' . $msgs_url . '">' . $msgs_str . '</a>';
491 $s .= $topbar_delimiter;
493 $delete_url = $base_uri . 'src/delete_message.php?mailbox=' . $urlMailbox .
494 '&message=' . $passed_id . '&';
495 if (!(isset($passed_ent_id) && $passed_ent_id)) {
496 if ($where && $what) {
497 $delete_url .= 'where=' . urlencode($where) . '&what=' . urlencode($what);
499 $delete_url .= 'sort=' . $sort . '&startMessage=' . $startMessage;
501 $s .= '<a href="' . $delete_url . '">' . _("Delete") . '</a>';
504 $comp_uri = $base_uri . 'src/compose.php' .
505 '?passed_id=' . $passed_id .
506 '&mailbox=' . $urlMailbox .
507 (isset($passed_ent_id)?
'&passed_ent_id='.$passed_ent_id:'');
509 if ($compose_new_win == '1') {
510 $link_open = '<a href="javascript:void(0)" onclick="comp_in_new(\'';
511 $link_close = '\')">';
513 $link_open = '<a href="';
516 if (($mailbox == $draft_folder) && ($save_as_draft)) {
517 $comp_alt_uri = $comp_uri . '&action=draft';
518 $comp_alt_string = _("Resume Draft");
519 } else if ($mailbox == $sent_folder) {
520 $comp_alt_uri = $comp_uri . '&action=edit_as_new';
521 $comp_alt_string = _("Edit Message as New");
523 if (isset($comp_alt_uri)) {
524 $s .= $topbar_delimiter;
525 $s .= $link_open . $comp_alt_uri . $link_close . $comp_alt_string . '</a>';
528 $s .= '</small></td><td align="center" width="33%"><small>';
530 if (!(isset($where) && isset($what)) && !$passed_ent_id) {
531 $prev = findPreviousMessage($mbx_response['EXISTS'], $passed_id);
532 $next = findNextMessage($passed_id);
534 $uri = $base_uri . 'src/read_body.php?passed_id='.$prev.
535 '&mailbox='.$urlMailbox.'&sort='.$sort.
536 '&startMessage='.$startMessage.'&show_more=0';
537 $s .= '<a href="'.$uri.'">'._("Previous").'</a>';
541 $s .= $topbar_delimiter;
543 $uri = $base_uri . 'src/read_body.php?passed_id='.$next.
544 '&mailbox='.$urlMailbox.'&sort='.$sort.
545 '&startMessage='.$startMessage.'&show_more=0';
546 $s .= '<a href="'.$uri.'">'._("Next").'</a>';
550 } else if (isset($passed_ent_id) && $passed_ent_id) {
551 /* code for navigating through attached message/rfc822 messages */
552 $url = set_url_var($PHP_SELF, 'passed_ent_id',0);
553 $s .= '<a href="'.$url.'">'._("View Message").'</a>';
554 $par_ent_id = $message->parent
->entity_id
;
556 $par_ent_id = substr($par_ent_id,0,-2);
557 $s .= $topbar_delimiter;
558 $url = set_url_var($PHP_SELF, 'passed_ent_id',$par_ent_id);
559 $s .= '<a href="'.$url.'">'._("Up").'</a>';
563 $s .= '</small></td>' . "\n" . '<td align="right" width="33%" nowrap><small>';
564 $comp_action_uri = $comp_uri . '&action=forward';
565 $s .= $link_open . $comp_action_uri . $link_close . _("Forward") . '</a>';
566 $s .= $topbar_delimiter;
568 if ($enable_forward_as_attachment) {
569 $comp_action_uri = $comp_uri . '&action=forward_as_attachment';
570 $s .= $link_open . $comp_action_uri . $link_close . _("Forward as Attachment") . '</a>';
571 $s .= $topbar_delimiter;
574 $comp_action_uri = decodeHeader($comp_uri . '&action=reply');
575 $s .= $link_open . $comp_action_uri . $link_close . _("Reply") . '</a>';
576 $s .= $topbar_delimiter;
578 $comp_action_uri = $comp_uri . '&action=reply_all';
579 $s .= $link_open . $comp_action_uri . $link_close . _("Reply All") . '</a>';
580 $s .= '</small></td></tr></table>';
581 do_hook("read_body_menu_top");
583 do_hook("read_body_menu_bottom");
586 function formatToolbar($mailbox, $passed_id, $passed_ent_id, $message, $color) {
589 $urlMailbox = urlencode($mailbox);
590 $url = $base_uri.'src/view_header.php?'.$_SERVER['QUERY_STRING'];
593 '<TD VALIGN="MIDDLE" ALIGN="RIGHT" WIDTH="20%"><B>' . _("Options") . ": </B></TD>\n" .
594 '<TD VALIGN="MIDDLE" ALIGN="LEFT" WIDTH="80%"><SMALL>' .
595 '<a href="'.$url.'">'._("View Full Header").'</a>';
597 /* Output the printer friendly link if we are in subtle mode. */
598 $s .= ' | ' .
599 printer_friendly_link($mailbox, $passed_id, $passed_ent_id, $color);
601 do_hook("read_body_header_right");
602 $s = "</SMALL></TD>\n" .
608 /***************************/
609 /* Main of read_body.php */
610 /***************************/
612 /* get the globals we may need */
614 $username = $_SESSION['username'];
615 $key = $_COOKIE['key'];
616 $onetimepad = $_SESSION['onetimepad'];
617 $msgs = $_SESSION['msgs'];
618 $base_uri = $_SESSION['base_uri'];
619 $delimiter = $_SESSION['delimiter'];
621 if (isset($_GET['passed_id'])) {
622 $passed_id = $_GET['passed_id'];
624 elseif (isset($_POST['passed_id'])) {
625 $passed_id = $_POST['passed_id'];
628 if (isset($_GET['passed_ent_id'])) {
629 $passed_ent_id = $_GET['passed_ent_id'];
631 elseif (isset($_POST['passed_ent_id'])) {
632 $passed_ent_id = $_POST['passed_ent_id'];
635 if (isset($_GET['sendreceipt'])) {
636 $sendreceipt = $_GET['sendreceipt'];
639 if (isset($_GET['sort'])) {
640 $sort = $_GET['sort'];
642 elseif (isset($_POST['sort'])) {
643 $sort = $_POST['sort'];
645 if (isset($_GET['startMessage'])) {
646 $startMessage = $_GET['startMessage'];
648 elseif (isset($_POST['startMessage'])) {
649 $startMessage = $_POST['startMessage'];
651 if (isset($_GET['show_more'])) {
652 $show_more = $_GET['show_more'];
654 if (isset($_GET['show_more_cc'])) {
655 $show_more_cc = $_GET['show_more_cc'];
657 if (isset($_GET['show_more_bcc'])) {
658 $show_more_bcc = $_GET['show_more_bcc'];
660 if (isset($_GET['mailbox'])) {
661 $mailbox = $_GET['mailbox'];
663 elseif (isset($_POST['mailbox'])) {
664 $mailbox = $_POST['mailbox'];
666 if (isset($_GET['where'])) {
667 $where = $_GET['where'];
669 if (isset($_GET['what'])) {
670 $what = $_GET['what'];
672 if (isset($_GET['view_hdr'])) {
673 $view_hdr = $_GET['view_hdr'];
675 if (isset($_SESSION['server_sort_array'])) {
676 $server_sort_array = $_SESSION['server_sort_array'];
678 if (isset($_SESSION['msgs'])) {
679 $msgs = $_SESSION['msgs'];
681 if (isset($_SESSION['msort'])) {
682 $msort = $_SESSION['msort'];
684 if (isset($_POST['move_id'])) {
685 $move_id = $_POST['move_id'];
687 if (isset($_SESSION['lastTargetMailbox'])) {
688 $lastTargetMailbox = $_SESSION['lastTargetMailbox'];
690 if (isset($_SESSION['messages'])) {
691 $messages = $_SESSION['messages'];
698 /* end of get globals */
699 global $uid_support, $sqimap_capabilities;
701 if (isset($mailbox)) {
702 $mailbox = urldecode( $mailbox );
705 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
706 $mbx_response = sqimap_mailbox_select($imapConnection, $mailbox, false, false, true);
710 * $message contains all information about the message
711 * including header and body
714 $uidvalidity = $mbx_response['UIDVALIDITY'];
716 if (!isset($messages[$uidvalidity])) {
717 $messages[$uidvalidity] = array();
719 if (!isset($messages[$uidvalidity][$passed_id]) ||
!$uid_support) {
720 $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
721 $FirstTimeSee = !$message->is_seen
;
722 $message->is_seen
= true;
723 $messages[$uidvalidity][$passed_id] = $message;
725 // $message = sqimap_get_message($imapConnection, $passed_id, $mailbox);
726 $message = $messages[$uidvalidity][$passed_id];
727 $FirstTimeSee = !$message->is_seen
;
730 if (isset($passed_ent_id) && $passed_ent_id) {
731 $message = $message->getEntity($passed_ent_id);
732 if ($message->type0
!= 'message' && $message->type1
!= 'rfc822') {
733 $message = $message->parent
;
735 $read = sqimap_run_command ($imapConnection, "FETCH $passed_id BODY[$passed_ent_id.HEADER]", true, $response, $msg, $uid_support);
736 $rfc822_header = new Rfc822Header();
737 $rfc822_header->parseHeader($read);
738 $message->rfc822_header
= $rfc822_header;
742 $header = $message->header
;
746 /****************************************/
747 /* Block for handling incoming url vars */
748 /****************************************/
750 if (isset($sendreceipt)) {
751 if ( !$message->is_mdnsent
) {
752 if (isset($identity) ) {
753 $final_recipient = getPref($data_dir, $username, 'email_address' . '0', '' );
755 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
758 $final_recipient = trim($final_recipient);
759 if ($final_recipient == '' ) {
760 $final_recipient = getPref($data_dir, $username, 'email_address', '' );
762 $supportMDN = ServerMDNSupport($mbx_response["PERMANENTFLAGS"]);
763 if ( SendMDN( $mailbox, $passed_id, $final_recipient, $message, $imapConnection ) > 0 && $supportMDN ) {
764 ToggleMDNflag( true, $imapConnection, $mailbox, $passed_id, $uid_support);
765 $message->is_mdnsent
= true;
766 $messages[$uidvalidity][$passed_id]=$message;
771 /***********************************************/
772 /* End of block for handling incoming url vars */
773 /***********************************************/
775 $msgs[$passed_id]['FLAG_SEEN'] = true;
778 do_hook('read_body_top');
779 if ($show_html_default == 1) {
780 $ent_ar = $message->findDisplayEntity(array());
782 $ent_ar = $message->findDisplayEntity(array(), array('text/plain'));
784 $cnt = count($ent_ar);
785 for ($i = 0; $i < $cnt; $i++
) {
786 $messagebody .= formatBody($imapConnection, $message, $color, $wrap_at, $ent_ar[$i], $passed_id, $mailbox);
788 $messagebody .= '<hr noshade size=1>';
792 displayPageHeader($color, $mailbox);
793 formatMenuBar($mailbox, $passed_id, $passed_ent_id, $message, $mbx_response);
794 formatEnvheader($mailbox, $passed_id, $passed_ent_id, $message, $color, $FirstTimeSee);
795 echo '<table width="100%" cellpadding="0" cellspacing="0" align="center" border="0">';
797 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[9].'">';
799 echo ' <table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">';
800 echo ' <tr bgcolor="'.$color[4].'"><td>';
801 echo ' <table cellpadding="1" cellspacing="5" align="left" border="0">';
802 echo ' <tr>' . html_tag( 'td', '<br>'. $messagebody."\n", 'left')
806 echo ' </table></td></tr>';
810 $attachmentsdisplay = formatAttachments($message,$ent_ar,$mailbox, $passed_id);
811 if ($attachmentsdisplay) {
813 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center"'.' border="0" bgcolor="'.$color[9].'">';
815 echo ' <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="'.$color[4].'">';
816 echo ' <tr><td ALIGN="left" bgcolor="'.$color[9].'">';
817 echo ' <b>' . _("Attachments") . ':</b>';
820 echo ' <table width="100%" cellpadding="2" cellspacing="2" align="center"'.' border="0" bgcolor="'.$color[0].'"><tr><td>';
821 echo $attachmentsdisplay;
822 echo ' </td></tr></table>';
823 echo ' </table></td></tr>';
824 echo ' </table></td></tr>';
830 /* show attached images inline -- if pref'fed so */
831 if (($attachment_common_show_images) &&
832 is_array($attachment_common_show_images_list)) {
833 foreach ($attachment_common_show_images_list as $img) {
834 $imgurl = SM_PATH
. 'src/download.php' .
836 'passed_id=' . urlencode($img['passed_id']) .
837 '&mailbox=' . urlencode($mailbox) .
838 '&ent_id=' . urlencode($img['ent_id']) .
839 '&absolute_dl=true';
841 echo html_tag( 'table', "\n" .
842 html_tag( 'tr', "\n" .
843 html_tag( 'td', '<img src="' . $imgurl . '">' ."\n", 'left'
846 'center', '', 'cellspacing=0 border="0" cellpadding="2"');
850 do_hook('read_body_bottom');
851 do_hook('html_bottom');
852 sqimap_logout($imapConnection);
853 /* sessions are written at the end of the script. it's better to register
854 them at the end so we avoid double session_register calls */
855 sqsession_register($messages,'messages');