6dfb53b5807af8886dd8437a6f5ff41b0c0e3380
6 * Copyright (c) 1999-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This implements functions that manipulate messages
10 * NOTE: Quite a few functions in this file are obsolete
13 * @package squirrelmail
18 * Copies specified messages to specified folder
19 * @param int $imap_stream The resource ID for the IMAP connection
20 * @param string $start Beginning of range to copy
21 * @param string $end End of the range to copy
22 * @param string $mailbox Which box to copy to
23 * @deprecated This function is obsolete and should not be used
25 function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
26 $read = sqimap_run_command ($imap_stream, "COPY $start:$end " . sqimap_encode_mailbox_name($mailbox), true, $response, $message, TRUE);
30 * copy a range of messages ($id) to another mailbox ($mailbox)
31 * @param int $imap_stream The resource ID for the IMAP socket
32 * @param string $id The list of messages to copy
33 * @param string $mailbox The destination to copy to
36 function sqimap_msgs_list_copy ($imap_stream, $id, $mailbox) {
37 $msgs_id = sqimap_message_list_squisher($id);
38 $read = sqimap_run_command ($imap_stream, "COPY $msgs_id " . sqimap_encode_mailbox_name($mailbox), true, $response, $message, TRUE);
42 * move a range of messages ($id) to another mailbox. Deletes the originals.
43 * @param int $imap_stream The resource ID for the IMAP socket
44 * @param string $id The list of messages to move
45 * @param string $mailbox The destination to move to
48 function sqimap_msgs_list_move ($imap_stream, $id, $mailbox) {
49 $msgs_id = sqimap_message_list_squisher($id);
50 $read = sqimap_run_command ($imap_stream, "COPY $msgs_id " . sqimap_encode_mailbox_name($mailbox), true, $response, $message, TRUE);
51 $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response,$message, TRUE);
56 * Deletes specified messages and moves them to trash if possible
57 * @deprecated This function is obsolete and should no longer be used
58 * @param int $imap_steam The resource ID for the IMAP connection
59 * @param string $start Start of range
60 * @param string $end End of range
61 * @param string $mailbox Mailbox messages are being deleted from
64 function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox, $bypass_trash=false) {
65 global $move_to_trash, $trash_folder, $auto_expunge;
67 if (($move_to_trash == true) && ($bypass_trash != true) &&
68 (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
69 sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
71 sqimap_messages_flag ($imap_stream, $start, $end, "Deleted", true);
74 function sqimap_msgs_list_delete ($imap_stream, $mailbox, $id, $bypass_trash=false) {
75 global $move_to_trash, $trash_folder;
76 $msgs_id = sqimap_message_list_squisher($id);
77 if (($move_to_trash == true) && ($bypass_trash != true) &&
78 (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder)) ) {
79 $read = sqimap_run_command ($imap_stream, "COPY $msgs_id " . sqimap_encode_mailbox_name($trash_folder), true, $response, $message, TRUE);
81 $read = sqimap_run_command ($imap_stream, "STORE $msgs_id +FLAGS (\\Deleted)", true, $response, $message, TRUE);
86 * Sets the specified messages with specified flag
88 function sqimap_messages_flag ($imap_stream, $start, $end, $flag, $handle_errors) {
89 $read = sqimap_run_command ($imap_stream, "STORE $start:$end +FLAGS (\\$flag)", $handle_errors, $response, $message, TRUE);
92 function sqimap_toggle_flag($imap_stream, $id, $flag, $set, $handle_errors) {
93 $msgs_id = sqimap_message_list_squisher($id);
94 $set_string = ($set ?
'+' : '-');
95 $read = sqimap_run_command ($imap_stream, "STORE $msgs_id ".$set_string."FLAGS ($flag)", $handle_errors, $response, $message, TRUE);
99 function sqimap_get_small_header ($imap_stream, $id, $sent) {
100 $res = sqimap_get_small_header_list($imap_stream, $id, $sent);
105 * Sort the message list and crunch to be as small as possible
106 * (overflow could happen, so make it small if possible)
108 function sqimap_message_list_squisher($messages_array) {
109 if( !is_array( $messages_array ) ) {
110 return $messages_array;
113 sort($messages_array, SORT_NUMERIC
);
115 while ($messages_array) {
116 $start = array_shift($messages_array);
118 while (isset($messages_array[0]) && $messages_array[0] == $end +
1) {
119 $end = array_shift($messages_array);
121 if ($msgs_str != '') {
125 if ($start != $end) {
126 $msgs_str .= ':' . $end;
133 * Retrieves an array with a sorted uid list. Sorting is done on the imap server
135 * @param resource $imap_stream IMAP socket connection
136 * @param string $sSortField Field to sort on
137 * @param bool $reverse Reverse order search
138 * @return array $id sorted uid list
140 function sqimap_get_sort_order ($imap_stream, $sSortField = 'UID',$reverse) {
141 global $default_charset,
145 $sort_test = array();
148 if ($sSortField == 'UID') {
149 $query = "SEARCH UID 1:*";
150 $uids = sqimap_run_command ($imap_stream, $query, true, $response, $message, true);
151 if (isset($uids[0])) {
152 if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
153 $id = preg_split("/ /", trim($regs[1]));
156 if (!preg_match("/OK/", $response)) {
159 $id = array_reverse($id);
164 $sSortField = 'REVERSE '.$sSortField;
166 $query = "SORT ($sSortField) ".strtoupper($default_charset).' ALL';
167 $sort_test = sqimap_run_command ($imap_stream, $query, true, $response, $message, TRUE);
169 if (isset($sort_test[0])) {
170 for ($i=0,$iCnt=count($sort_test);$i<$iCnt;++
$i) {
171 if (preg_match("/^\* SORT (.+)$/", $sort_test[$i], $regs)) {
172 $id = preg_split("/ /", trim($regs[1]));
177 if (!preg_match("/OK/", $response)) {
185 * Retrieves an array with a sorted uid list. Sorting is done by SquirrelMail
187 * @param resource $imap_stream IMAP socket connection
188 * @param string $sSortField Field to sort on
189 * @param bool $reverse Reverse order search
190 * @return array $aUid sorted uid list
192 function get_squirrel_sort ($imap_stream, $sSortField, $reverse = false) {
194 if ($sSortField == 'UID') {
195 // FIX ME: this is not needed. Try to find another way to solve this
196 $query = "SEARCH UID 1:*";
197 $uids = sqimap_run_command ($imap_stream, $query, true, $response, $message, true);
198 if (isset($uids[0])) {
199 if (preg_match("/^\* SEARCH (.+)$/", $uids[0], $regs)) {
200 $msgs = preg_split("/ /", trim($regs[1]));
203 if (!preg_match("/OK/", $response)) {
206 } else if ($sSortField != 'RFC822.SIZE' && $sSortField != 'INTERNALDATE') {
207 $msgs = sqimap_get_small_header_list($imap_stream, false, '*',
208 array($sSortField), array('UID'));
210 $msgs = sqimap_get_small_header_list($imap_stream, false, '*',
211 array(), array('UID', $sSortField));
215 switch ($sSortField) {
216 // natcasesort section
221 array_walk($msgs, create_function('&$v,&$k,$f',
222 '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
223 $addr = parseAddress($v[$f]);
224 $v[$f] = ($addr[0][1]) ? decodeHeader($addr[0][1]):$addr[0][0];'),$sSortField);
230 array_walk($msgs, create_function('&$v,&$k,$f',
231 '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
232 $v[$f] = strtolower(decodeHeader(trim($v[$f])));
233 $v[$f] = (preg_match("/^(vedr|sv|re|aw|\[\w\]):\s*(.*)$/si", $v[$f], $matches)) ?
234 $matches[2] : $v[$f];'),$sSortField);
237 foreach ($msgs as $item) {
238 $aUid[$item['ID']] = $item[$sSortField];
241 $aUid = array_keys($aUid);
243 $aUid = array_reverse($aUid);
246 // \natcasesort section
247 // sort_numeric section
251 array_walk($msgs, create_function('&$v,$k,$f',
252 '$v[$f] = (isset($v[$f])) ? $v[$f] : "";
253 $v[$f] = getTimeStamp(explode(" ",$v[$f]));'),$sSortField);
259 // redefine $sSortField to maintain the same namespace between
260 // server-side sorting and squirrelmail sorting
261 $sSortField = 'SIZE';
263 foreach ($msgs as $item) {
264 $aUid[$item['ID']] = (isset($item[$sSortField])) ?
$item[$sSortField] : 0;
267 arsort($aUid,SORT_NUMERIC
);
269 asort($aUid, SORT_NUMERIC
);
271 $aUid = array_keys($aUid);
273 // \sort_numeric section
275 $aUid = array_reverse($msgs);
282 * Returns an indent array for printMessageinfo()
283 * This represents the amount of indent needed (value),
284 * for this message number (key)
288 * Notes for future work:
289 * indent_array should contain: indent_level, parent and flags,
291 * To achieve that we need to define the following flags:
296 * a node has sibling nodes if it's not the last node
297 * a node has no sibling nodes if it's the last node
298 * By using binary comparations we can store the flag in one var
301 * -1 par = 0, level = 0, flag = 1 + 2 + 4 = 7 (haschildren, isfirst, islast)
302 * \-2 par = 1, level = 1, flag = 0 + 2 = 2 (hasnochildren, isfirst)
303 * |-3 par = 1, level = 1, flag = 1 + 4 = 5 (haschildren, islast)
304 * \-4 par = 3, level = 2, flag = 1 + 2 + 4 = 7 (haschildren, isfirst, islast)
305 * \-5 par = 4, level = 3, flag = 0 + 2 + 4 = 6 (hasnochildren, isfirst, islast)
307 function get_parent_level ($thread_new) {
313 * loop through the threads and take unwanted characters out
314 * of the thread string then chop it up
316 for ($i=0;$i<count($thread_new);$i++
) {
317 $thread_new[$i] = preg_replace("/\s\(/", "(", $thread_new[$i]);
318 $thread_new[$i] = preg_replace("/(\d+)/", "$1|", $thread_new[$i]);
319 $thread_new[$i] = preg_split("/\|/", $thread_new[$i], -1, PREG_SPLIT_NO_EMPTY
);
321 $indent_array = array();
323 $thread_new = array();
325 /* looping through the parts of one message thread */
327 for ($i=0;$i<count($thread_new);$i++
) {
328 /* first grab the parent, it does not indent */
330 if (isset($thread_new[$i][0])) {
331 if (preg_match("/(\d+)/", $thread_new[$i][0], $regs)) {
335 $indent_array[$parent] = 0;
338 * now the children, checking each thread portion for
339 * ),(, and space, adjusting the level and space values
340 * to get the indent level
347 for ($k=1,$iCnt=count($thread_new[$i])-1;$k<$iCnt;++
$k) {
348 $chars = count_chars($thread_new[$i][$k], 1);
349 if (isset($chars['40'])) { /* testing for ( */
350 $level +
= $chars['40'];
352 if (isset($chars['41'])) { /* testing for ) */
353 $level -= $chars['41'];
355 /* if we were faking lets stop, this portion
356 * of the thread is over
358 if ($level == $cutoff) {
362 if (isset($chars['32'])) { /* testing for space */
363 if (!isset($spaces[$level])) {
366 $spaces[$level] +
= $chars['32'];
368 for ($x=0;$x<=$level;$x++
) {
369 if (isset($spaces[$x])) {
370 $spaces_total +
= $spaces[$x];
373 $indent = $level +
$spaces_total;
374 /* must have run into a message that broke the thread
375 * so we are adjusting for that portion
378 $indent = $indent +
1;
380 if (preg_match("/(\d+)/", $thread_new[$i][$k], $regs)) {
383 /* the thread must be broken if $indent == 0
384 * so indent the message once and start faking it
391 /* dont need abs but if indent was negative
394 $indent_array[$child] = ($indent < 0) ?
0 : $indent;
398 return $indent_array;
403 * Returns an array with each element as a string representing one
404 * message-thread as returned by the IMAP server.
406 function get_thread_sort ($imap_stream) {
407 global $thread_new, $sort_by_ref, $default_charset, $server_sort_array, $indent_array;
408 if (sqsession_is_registered('thread_new')) {
409 sqsession_unregister('thread_new');
411 if (sqsession_is_registered('indent_array')) {
412 sqsession_unregister('indent_array');
414 if (sqsession_is_registered('server_sort_array')) {
415 sqsession_unregister('server_sort_array');
417 $thread_temp = array ();
418 if ($sort_by_ref == 1) {
419 $sort_type = 'REFERENCES';
421 $sort_type = 'ORDEREDSUBJECT';
423 $query = "THREAD $sort_type ".strtoupper($default_charset)." ALL";
424 $thread_test = sqimap_run_command ($imap_stream, $query, true, $response, $message, TRUE);
425 if (isset($thread_test[0])) {
426 for ($i=0,$iCnt=count($thread_test);$i<$iCnt;++
$i) {
427 if (preg_match("/^\* THREAD (.+)$/", $thread_test[$i], $regs)) {
428 $thread_list = trim($regs[1]);
435 if (!preg_match("/OK/", $response)) {
436 $server_sort_array = 'no';
437 return $server_sort_array;
439 if (isset($thread_list)) {
440 $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY
);
443 $char_count = count($thread_temp);
445 $thread_new = array();
449 * parse the thread response into separate threads
454 * [2] => (1599 759 959 37)
456 * [4] => ((933)(1891))
457 * [5] => (1030 (1497)(845)(1637))
459 for ($i=0,$iCnt=count($thread_temp);$i<$iCnt;$i++
) {
460 if ($thread_temp[$i] != ')' && $thread_temp[$i] != '(') {
461 $thread_new[$k] = $thread_new[$k] . $thread_temp[$i];
462 } elseif ($thread_temp[$i] == '(') {
463 $thread_new[$k] .= $thread_temp[$i];
465 } elseif ($thread_temp[$i] == ')') {
467 $thread_new[$k] .= $thread_temp[$i];
468 $counter = $counter - 1;
470 $thread_new[$k] .= $thread_temp[$i];
472 $thread_new[$k] = "";
473 $counter = $counter - 1;
477 sqsession_register($thread_new, 'thread_new');
478 $thread_new = array_reverse($thread_new);
479 /* place the threads after each other in one string */
480 $thread_list = implode(" ", $thread_new);
481 $thread_list = str_replace("(", " ", $thread_list);
482 $thread_list = str_replace(")", " ", $thread_list);
483 $thread_list = preg_split("/\s/", $thread_list, -1, PREG_SPLIT_NO_EMPTY
);
484 $server_sort_array = $thread_list;
486 $indent_array = get_parent_level ($thread_new);
487 sqsession_register($indent_array, 'indent_array');
489 sqsession_register($server_sort_array, 'server_sort_array');
494 function elapsedTime($start) {
495 $stop = gettimeofday();
496 $timepassed = 1000000 * ($stop['sec'] - $start['sec']) +
$stop['usec'] - $start['usec'];
500 // only used in sqimap_get_small_header_list
501 function parseString($read,&$i) {
507 $iPos = strpos($read,'"',$iPos);
509 if ($iPos && $read{$iPos -1} != '\\') {
510 $s = substr($read,$i,($iPos-$i));
515 if ($iPos > strlen($read)) {
519 } else if ($char == '{') {
522 $iPos = strpos($read,'}',$i);
524 $lit_cnt = substr($read, $i, $iPos - $i);
525 $i +
= strlen($lit_cnt) +
3; /* skip } + \r + \n */
526 /* Now read the literal */
527 $s = ($lit_cnt ?
substr($read,$i,$lit_cnt): '');
529 /* temp bugfix (SM 1.5 will have a working clean version)
530 too much work to implement that version right now */
532 } else { /* should never happen */
533 $i +
= 3; /* } + \r + \n */
543 // only used in sqimap_get_small_header_list
544 function parseArray($read,&$i) {
545 $i = strpos($read,'(',$i);
546 $i_pos = strpos($read,')',$i);
547 $s = substr($read,$i+
1,$i_pos - $i -1);
548 $a = explode(' ',$s);
557 function sqimap_get_small_header_list ($imap_stream, $msg_list, $show_num=false,
558 $aHeaderFields = array('Date', 'To', 'Cc', 'From', 'Subject', 'X-Priority', 'Content-Type'),
559 $aFetchItems = array('FLAGS', 'RFC822.SIZE', 'INTERNALDATE')) {
562 $read_list = array();
564 if (array_search('UID',$aFetchItems,true) !== false) {
570 /* Get the small headers for each message in $msg_list */
571 if ($show_num != '999999' && $show_num != '*' ) {
572 $msgs_str = sqimap_message_list_squisher($msg_list);
574 * We need to return the data in the same order as the caller supplied
575 * in $msg_list, but IMAP servers are free to return responses in
576 * whatever order they wish... So we need to re-sort manually
579 for ($i = 0; $i < sizeof($msg_list); $i++
) {
580 $messages["$msg_list[$i]"] = array();
594 $query = "FETCH $msgs_str (";
595 if (count($aFetchItems)) {
596 $sFetchItems = implode(' ',$aFetchItems);
598 if (count($aHeaderFields)) {
599 $sHeaderFields = implode(' ',$aHeaderFields);
600 $sFetchItems .= ' BODY.PEEK[HEADER.FIELDS ('.$sHeaderFields.')]';
602 $query .= trim($sFetchItems) . ')';
604 $read_list = sqimap_run_command_list ($imap_stream, $query, true, $response, $message, $bUidFetch);
607 foreach ($read_list as $r) {
608 // use unset because we do isset below
609 $read = implode('',$r);
612 * #id<space>FETCH<space>(
615 /* extract the message id */
616 $i_space = strpos($read,' ',2);
617 $id = substr($read,2,$i_space-2);
618 $fetch = substr($read,$i_space+
1,5);
619 if (!is_numeric($id) && $fetch !== 'FETCH') {
620 $msg['ERROR'] = $read; // htmlspecialchars should be done just before display. this is backend code
623 $i = strpos($read,'(',$i_space+
5);
624 $read = substr($read,$i+
1);
625 $i_len = strlen($read);
627 while ($i < $i_len && $i !== false) {
629 $read = trim(substr($read,$i));
630 $i_len = strlen($read);
631 $i = strpos($read,' ');
632 $arg = substr($read,0,$i);
637 $i_pos = strpos($read,' ',$i);
639 $i_pos = strpos($read,')',$i);
642 $unique_id = substr($read,$i,$i_pos-$i);
649 $flags = parseArray($read,$i);
650 if (!$flags) break 3;
652 foreach ($flags as $flag) {
653 $flag = strtolower($flag);
654 $aFlags[$flag] = true;
656 $msg['FLAGS'] = $aFlags;
659 $i_pos = strpos($read,' ',$i);
661 $i_pos = strpos($read,')',$i);
664 $msg['SIZE'] = substr($read,$i,$i_pos-$i);
672 break; // to be implemented, moving imap code out of the nessages class
673 sqimap_parse_address($read,$i,$msg);
674 break; // to be implemented, moving imap code out of the nessages class
675 case 'BODYSTRUCTURE':
678 $msg['INTERNALDATE'] = str_replace(' ', ' ',parseString($read,$i));
680 case 'BODY.PEEK[HEADER.FIELDS':
681 case 'BODY[HEADER.FIELDS':
682 $i = strpos($read,'{',$i);
683 $header = parseString($read,$i);
684 if ($header === false) break 2;
685 /* First we replace all \r\n by \n, and unfold the header */
686 $hdr = trim(str_replace(array("\r\n", "\n\t", "\n "),array("\n", ' ', ' '), $header));
687 /* Now we can make a new header array with */
688 /* each element representing a headerline */
689 $hdr = explode("\n" , $hdr);
690 foreach ($hdr as $line) {
691 $pos = strpos($line, ':');
693 $field = strtolower(substr($line, 0, $pos));
694 if (!strstr($field,' ')) { /* valid field */
695 $value = trim(substr($line, $pos+
1));
698 case 'to': $msg['TO'] = $value; break;
699 case 'cc': $msg['CC'] = $value; break;
700 case 'from': $msg['FROM'] = $value; break;
702 $msg['DATE'] = str_replace(' ', ' ', $value);
704 case 'x-priority': $msg['PRIORITY'] = $value; break;
705 case 'subject': $msg['SUBJECT'] = $value; break;
708 if ($pos = strpos($type, ";")) {
709 $type = substr($type, 0, $pos);
711 $type = explode("/", $type);
712 if(!is_array($type)) {
713 $msg['TYPE0'] = 'text';
714 $msg['TYPE1'] = 'plain';
729 $msg['ID'] = $unique_id;
731 $messages[$msgi] = $msg;
734 array_reverse($messages);
738 function sqimap_parse_envelope($read, &$i, &$msg) {
742 for ($cnt = strlen($read); ($i < $cnt) && ($read{$i} != ')'); ++
$i) {
743 $char = strtoupper($read{$i});
747 $arg_a[] = parseString($read,$i);
751 /* probably NIL argument */
752 if (strtoupper(substr($read, $i, 3)) == 'NIL') {
759 /* Address structure (with group support)
760 * Note: Group support is useless on SMTP connections
761 * because the protocol doesn't support it
766 for (; $i < $cnt && $read{$i} != ')'; ++
$i) {
767 if ($read{$i} == '(') {
768 $addr = sqimap_parse_address($read, $i);
769 if (($addr[3] == '') && ($addr[2] != '')) {
774 } else if ($group && ($addr[3] == '') && ($addr[2] == '')) {
776 if ($a == ($j+
1)) { /* no group members */
777 $group_addr[4] = $group;
779 $group_addr[0] = "$group: Undisclosed recipients;";
780 $addr_a[] = $group_addr;
796 if (count($arg_a) > 9) {
797 $d = strtr($arg_a[0], array(' ' => ' '));
798 $d = explode(' ', $d);
799 if (!$arg_a[1]) $arg_1[1] = '';
800 $msg['DATE'] = $d; /* argument 1: date */
801 $msg['SUBJECT'] = $arg_a[1]; /* argument 2: subject */
802 $msg['FROM'] = is_array($arg_a[2]) ?
$arg_a[2][0] : ''; /* argument 3: from */
803 $msg['SENDER'] = is_array($arg_a[3]) ?
$arg_a[3][0] : ''; /* argument 4: sender */
804 $msg['REPLY-TO'] = is_array($arg_a[4]) ?
$arg_a[4][0] : ''; /* argument 5: reply-to */
805 $msg['TO'] = $arg_a[5]; /* argument 6: to */
806 $msg['CC'] = $arg_a[6]; /* argument 7: cc */
807 $msg['BCC'] = $arg_a[7]; /* argument 8: bcc */
808 $msg['IN-REPLY-TO'] = $arg_a[8]; /* argument 9: in-reply-to */
809 $msg['MESSAGE-ID'] = $arg_a[9]; /* argument 10: message-id */
813 function sqimap_parse_address($read, &$i) {
815 for (; $read{$i} != ')'; ++
$i) {
816 $char = strtoupper($read{$i});
819 case '"': $arg_a[] = parseString($read,$i); break;
822 if (strtoupper(substr($read, $i, 3)) == 'NIL') {
831 if (count($arg_a) == 4) {
834 // $adr = new AddressStructure();
835 // $adr->personal = $arg_a[0];
836 // $adr->adl = $arg_a[1];
837 // $adr->mailbox = $arg_a[2];
838 // $adr->host = $arg_a[3];
846 * Returns a message array with all the information about a message.
847 * See the documentation folder for more information about this array.
849 function sqimap_get_message ($imap_stream, $id, $mailbox) {
850 // typecast to int to prohibit 1:* msgs sets
853 $read = sqimap_run_command ($imap_stream, "FETCH $id (FLAGS BODYSTRUCTURE)", true, $response, $message, TRUE);
855 if (preg_match('/.+FLAGS\s\((.*)\)\s/AUi',$read[0],$regs)) {
856 if (trim($regs[1])) {
857 $flags = preg_split('/ /', $regs[1],-1,'PREG_SPLIT_NI_EMPTY');
861 /* the message was not found, maybe the mailbox was modified? */
862 global $sort, $startMessage, $color;
864 $errmessage = _("The server couldn't find the message you requested.") .
865 '<p>'._("Most probably your message list was out of date and the message has been moved away or deleted (perhaps by another program accessing the same mailbox).");
866 /* this will include a link back to the message list */
867 error_message($errmessage, $mailbox, $sort, (int) $startMessage, $color);
870 $bodystructure = implode('',$read);
871 $msg = mime_structure($bodystructure,$flags);
872 $read = sqimap_run_command ($imap_stream, "FETCH $id BODY[HEADER]", true, $response, $message, TRUE);
873 $rfc822_header = new Rfc822Header();
874 $rfc822_header->parseHeader($read);
875 $msg->rfc822_header
= $rfc822_header;