6 * Copyright (c) 1999-2002 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * This implements functions that manipulate messages
14 /* Copies specified messages to specified folder */
15 function sqimap_messages_copy ($imap_stream, $start, $end, $mailbox) {
16 $read = sqimap_run_command ($imap_stream, "COPY $start:$end \"$mailbox\"", true, $response, $message);
19 /* Deletes specified messages and moves them to trash if possible */
20 function sqimap_messages_delete ($imap_stream, $start, $end, $mailbox) {
21 global $move_to_trash, $trash_folder, $auto_expunge;
23 if (($move_to_trash == true) && (sqimap_mailbox_exists($imap_stream, $trash_folder) && ($mailbox != $trash_folder))) {
24 sqimap_messages_copy ($imap_stream, $start, $end, $trash_folder);
26 sqimap_messages_flag ($imap_stream, $start, $end, "Deleted");
29 /* Sets the specified messages with specified flag */
30 function sqimap_messages_flag ($imap_stream, $start, $end, $flag) {
31 $read = sqimap_run_command ($imap_stream, "STORE $start:$end +FLAGS (\\$flag)", true, $response, $message);
34 /* Remove specified flag from specified messages */
35 function sqimap_messages_remove_flag ($imap_stream, $start, $end, $flag) {
36 $read = sqimap_run_command ($imap_stream, "STORE $start:$end -FLAGS (\\$flag)", true, $response, $message);
39 /* Returns some general header information -- FROM, DATE, and SUBJECT */
41 var $from = '', $subject = '', $date = '', $to = '',
42 $priority = 0, $message_id = 0, $cc = '';
45 function sqimap_get_small_header ($imap_stream, $id, $sent) {
46 $res = sqimap_get_small_header_list($imap_stream, array($id), $sent);
51 * Sort the message list and crunch to be as small as possible
52 * (overflow could happen, so make it small if possible)
54 function sqimap_message_list_squisher($messages_array) {
55 if( !is_array( $messages_array ) ) {
58 sort($messages_array, SORT_NUMERIC
);
60 while ($messages_array) {
61 $start = array_shift($messages_array);
63 while (isset($messages_array[0]) && $messages_array[0] == $end +
1) {
64 $end = array_shift($messages_array);
66 if ($msgs_str != '') {
71 $msgs_str .= ':' . $end;
78 /* returns the references header lines */
79 function get_reference_header ($imap_stream, $message) {
80 $responses = array ();
81 $sid = sqimap_session_id();
84 $query = "$sid FETCH $message BODY[HEADER.FIELDS (References)]\r\n";
85 fputs ($imap_stream, $query);
86 $responses = sqimap_read_data_list($imap_stream, $sid, true, $responses, $message);
87 if (!eregi("^\\* ([0-9]+) FETCH", $responses[0][0], $regs)) {
88 $responses = array ();
94 /* get sort order from server and
95 * return it as the $id array for
99 function sqimap_get_sort_order ($imap_stream, $sort) {
100 global $default_charset, $thread_sort_messages,
101 $internal_date_sort, $server_sort_array,
102 $sent_folder, $mailbox;
104 if (session_is_registered('server_sort_array')) {
105 session_unregister('server_sort_array');
108 $qty = sqimap_get_num_messages ($imap_stream, $mailbox);
109 $server_sort_array = range(1, $qty);
110 session_register('server_sort_array');
111 return $server_sort_array;
113 $sid = sqimap_session_id();
116 $server_sort_array = array();
117 $sort_test = array();
119 $sort_on = array (0=> 'DATE',
125 if ($internal_date_sort == true) {
126 $sort_on[0] = 'ARRIVAL';
127 $sort_on[1] = 'ARRIVAL';
129 if ($sent_folder == $mailbox) {
133 if (!empty($sort_on[$sort])) {
134 $sort_query = "$sid SORT ($sort_on[$sort]) ".strtoupper($default_charset)." ALL\r\n";
135 fputs($imap_stream, $sort_query);
136 $sort_test = sqimap_read_data($imap_stream, $sid, false, $response, $message);
138 if (isset($sort_test[0])) {
139 if (preg_match("/^\* SORT (.+)$/", $sort_test[0], $regs)) {
140 $server_sort_array = preg_split("/ /", trim($regs[1]));
143 if ($sort == 0 ||
$sort == 2 ||
$sort == 4) {
144 $server_sort_array = array_reverse($server_sort_array);
146 if (!preg_match("/OK/", $response)) {
147 $server_sort_array = 'no';
149 session_register('server_sort_array');
150 return $server_sort_array;
153 /* returns an indent array for printMessageinfo()
154 this represents the amount of indent needed (value)
155 for this message number (key)
158 function get_parent_level ($imap_stream) {
159 global $sort_by_ref, $default_charset, $thread_new;
164 /* loop through the threads and take unwanted characters out
165 of the thread string then chop it up
167 for ($i=0;$i<count($thread_new);$i++
) {
168 $thread_new[$i] = preg_replace("/\s\(/", "(", $thread_new[$i]);
169 $thread_new[$i] = preg_replace("/(\d+)/", "$1|", $thread_new[$i]);
170 $thread_new[$i] = preg_split("/\|/", $thread_new[$i], -1, PREG_SPLIT_NO_EMPTY
);
172 $indent_array = array();
174 $thread_new = array();
176 /* looping through the parts of one message thread */
178 for ($i=0;$i<count($thread_new);$i++
) {
179 /* first grab the parent, it does not indent */
181 if (isset($thread_new[$i][0])) {
182 if (preg_match("/(\d+)/", $thread_new[$i][0], $regs)) {
186 $indent_array[$parent] = 0;
188 /* now the children, checking each thread portion for
189 ),(, and space, adjusting the level and space values
190 to get the indent level
197 for ($k=1;$k<(count($thread_new[$i]))-1;$k++
) {
198 $chars = count_chars($thread_new[$i][$k], 1);
199 if (isset($chars['40'])) { /* testing for ( */
200 $level = $level +
$chars['40'];
202 if (isset($chars['41'])) { /* testing for ) */
203 $level = $level - $chars['41'];
205 /* if we were faking lets stop, this portion
206 of the thread is over
208 if ($level == $cutoff) {
212 if (isset($chars['32'])) { /* testing for space */
213 if (!isset($spaces[$level])) {
216 $spaces[$level] = $spaces[$level] +
$chars['32'];
218 for ($x=0;$x<=$level;$x++
) {
219 if (isset($spaces[$x])) {
220 $spaces_total = $spaces_total +
$spaces[$x];
223 $indent = $level +
$spaces_total;
224 /* must have run into a message that broke the thread
225 so we are adjusting for that portion
228 $indent = $indent +
1;
230 if (preg_match("/(\d+)/", $thread_new[$i][$k], $regs)) {
233 /* the thread must be broken if $indent == 0
234 so indent the message once and start faking it
241 /* dont need abs but if indent was negative
244 $indent_array[$child] = abs($indent);
248 return $indent_array;
252 /* returns an array with each element as a string
253 representing one message thread as returned by
257 function get_thread_sort ($imap_stream) {
258 global $thread_new, $sort_by_ref, $default_charset, $server_sort_array;
259 if (session_is_registered('thread_new')) {
260 session_unregister('thread_new');
262 if (session_is_registered('server_sort_array')) {
263 session_unregister('server_srot_array');
265 $sid = sqimap_session_id();
266 $thread_temp = array ();
267 if ($sort_by_ref == 1) {
268 $sort_type = 'REFERENCES';
271 $sort_type = 'ORDEREDSUBJECT';
273 $thread_query = "$sid THREAD $sort_type ".strtoupper($default_charset)." ALL\r\n";
274 fputs($imap_stream, $thread_query);
275 $thread_test = sqimap_read_data($imap_stream, $sid, false, $response, $message);
276 if (isset($thread_test[0])) {
277 if (preg_match("/^\* THREAD (.+)$/", $thread_test[0], $regs)) {
278 $thread_list = trim($regs[1]);
284 if (!preg_match("/OK/", $response)) {
285 $server_sort_array = 'no';
286 return $server_sort_array;
288 if (isset($thread_list)) {
289 $thread_temp = preg_split("//", $thread_list, -1, PREG_SPLIT_NO_EMPTY
);
291 $char_count = count($thread_temp);
293 $thread_new = array();
296 for ($i=0;$i<$char_count;$i++
) {
297 if ($thread_temp[$i] != ')' && $thread_temp[$i] != '(') {
298 $thread_new[$k] = $thread_new[$k] . $thread_temp[$i];
300 elseif ($thread_temp[$i] == '(') {
301 $thread_new[$k] .= $thread_temp[$i];
304 elseif ($thread_temp[$i] == ')') {
306 $thread_new[$k] .= $thread_temp[$i];
307 $counter = $counter - 1;
310 $thread_new[$k] .= $thread_temp[$i];
312 $thread_new[$k] = "";
313 $counter = $counter - 1;
317 session_register('thread_new');
318 $thread_new = array_reverse($thread_new);
319 $thread_list = implode(" ", $thread_new);
320 $thread_list = str_replace("(", " ", $thread_list);
321 $thread_list = str_replace(")", " ", $thread_list);
322 $thread_list = preg_split("/\s/", $thread_list, -1, PREG_SPLIT_NO_EMPTY
);
323 $server_sort_array = $thread_list;
324 session_register('server_sort_array');
328 function elapsedTime($start) {
329 $stop = gettimeofday();
330 $timepassed = 1000000 * ($stop['sec'] - $start['sec']) +
$stop['usec'] - $start['usec'];
335 function sqimap_get_small_header_list ($imap_stream, $msg_list, $issent) {
336 global $squirrelmail_language, $color, $data_dir, $username, $imap_server_type;
337 $start = gettimeofday();
338 /* Get the small headers for each message in $msg_list */
339 $sid = sqimap_session_id();
340 $maxmsg = sizeof($msg_list);
341 $msgs_str = sqimap_message_list_squisher($msg_list);
343 $read_list = array();
345 * We need to return the data in the same order as the caller supplied
346 * in $msg_list, but IMAP servers are free to return responses in
347 * whatever order they wish... So we need to re-sort manually
349 for ($i = 0; $i < sizeof($msg_list); $i++
) {
350 $id2index[$msg_list[$i]] = $i;
353 $internaldate = getPref($data_dir, $username, 'internal_date_sort');
355 $query = "$sid FETCH $msgs_str (FLAGS RFC822.SIZE INTERNALDATE BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject X-Priority Content-Type)])\r\n";
357 $query = "$sid FETCH $msgs_str (FLAGS RFC822.SIZE BODY.PEEK[HEADER.FIELDS (Date To From Cc Subject X-Priority Content-Type)])\r\n";
359 fputs ($imap_stream, $query);
360 $readin_list = sqimap_read_data_list($imap_stream, $sid, true, $response, $message);
362 foreach ($readin_list as $r) {
363 if (!preg_match("/^\\*\s+([0-9]+)\s+FETCH/iAU",$r[0], $regs)) {
364 set_up_language($squirrelmail_language);
365 echo '<br><b><font color=$color[2]>' .
366 _("ERROR : Could not complete request.") .
368 _("Unknown response from IMAP server: ") . ' 1.' .
369 $r[0] . "</font><br>\n";
371 } else if (! isset($id2index[$regs[1]]) ||
!count($id2index[$regs[1]])) {
372 set_up_language($squirrelmail_language);
373 echo '<br><b><font color=$color[2]>' .
374 _("ERROR : Could not complete request.") .
376 _("Unknown message number in reply from server: ") .
377 $regs[1] . "</font><br>\n";
379 $read_list[$id2index[$regs[1]]] = $r;
387 "/^X-Priority:(.*)\$/AU",
390 "/^Subject:(.*)\$/AU",
391 "/^Content-Type:(.*)\$/AU"
395 for ($msgi = 0; $msgi < $maxmsg; $msgi++
) {
396 $subject = _("(no subject)");
397 $from = _("Unknown Sender");
407 $flag_answered = false;
408 $flag_deleted = false;
409 $flag_flagged = false;
410 $read = $read_list[$msgi];
413 foreach ($read as $read_part) {
414 //unfold multi-line headers
415 while ($prevline && strspn($read_part, "\t ") > 0) {
416 $read_part = substr($prevline, 0, -2) . ' ' . ltrim($read_part);
418 $prev_line = $read_part;
420 if ($read_part{0} == '*') {
422 if (preg_match ("/^.+INTERNALDATE\s+\"(.+)\".+/iUA",$read_part, $reg)) {
423 $tmpdate = trim($reg[1]);
424 $tmpdate = str_replace(' ',' ',$tmpdate);
425 $tmpdate = explode(' ',$tmpdate);
426 $date = str_replace('-',' ',$tmpdate[0]) . " " .
431 if (preg_match ("/^.+RFC822.SIZE\s+(\d+).+/iA",$read_part, $reg)) {
434 if (preg_match("/^.+FLAGS\s+\((.*)\).+/iUA", $read_part, $regs)) {
435 $flags = explode(' ',trim($regs[1]));
436 foreach ($flags as $flag) {
437 $flag = strtolower($flag);
438 if ($flag == '\\seen') {
440 } else if ($flag == '\\answered') {
441 $flag_answered = true;
442 } else if ($flag == '\\deleted') {
443 $flag_deleted = true;
444 } else if ($flag == '\\flagged') {
445 $flag_flagged = true;
450 $firstchar = $read_part{0};
451 if ($firstchar == 'T') {
452 $regpattern = $patterns[0];
454 } else if ($firstchar == 'F') {
455 $regpattern = $patterns[1];
457 } else if ($firstchar == 'X') {
458 $regpattern = $patterns[2];
460 } else if ($firstchar == 'C') {
461 if (strtolower($read_part{1}) == 'c') {
462 $regpattern = $patterns[3];
464 } else if (strtolower($read_part{1}) == 'o') {
465 $regpattern = $patterns[6];
468 } else if ($firstchar == 'D' && !$internaldate ) {
469 $regpattern = $patterns[4];
471 } else if ($firstchar == 'S') {
472 $regpattern = $patterns[5];
474 } else $regpattern = '';
477 if (preg_match ($regpattern, $read_part, $regs)) {
486 $priority = $regs[1];
495 $subject = htmlspecialchars(trim($regs[1]));
496 if ($subject == "") {
497 $subject = _("(no subject)");
501 $type = strtolower(trim($regs[1]));
502 if ($pos = strpos($type, ";")) {
503 $type = substr($type, 0, $pos);
505 $type = explode("/", $type);
506 if (!isset($type[1])) {
518 $header = new small_header
;
520 $header->from
= (trim($to) != '' ?
$to : '(' ._("No To Address") . ')');
522 $header->from
= $from;
525 $header->date
= $date;
526 $header->subject
= $subject;
528 $header->priority
= $priority;
529 $header->message_id
= $messageid;
531 $header->size
= $size;
532 $header->type0
= $type[0];
533 $header->type1
= $type[1];
534 $header->flag_seen
= $flag_seen;
535 $header->flag_answered
= $flag_answered;
536 $header->flag_deleted
= $flag_deleted;
537 $header->flag_flagged
= $flag_flagged;
538 $header->inrepto
= $inrepto;
541 // echo 'processtime (us): ' . elapsedtime($start) .'<BR>';
548 /* Returns the flags for the specified messages */
549 function sqimap_get_flags ($imap_stream, $i) {
550 $read = sqimap_run_command ($imap_stream, "FETCH $i:$i FLAGS", true, $response, $message);
551 if (ereg('FLAGS(.*)', $read[0], $regs)) {
552 return explode(' ', trim(ereg_replace('[\\(\\)\\\\]', '', $regs[1])));
554 return array('None');
557 function sqimap_get_flags_list ($imap_stream, $msg_list) {
558 $msgs_str = sqimap_message_list_squisher($msg_list);
559 for ($i = 0; $i < sizeof($msg_list); $i++
) {
560 $id2index[$msg_list[$i]] = $i;
562 $result_list = sqimap_run_command_list ($imap_stream, "FETCH $msgs_str FLAGS", true, $response, $message);
563 $result_flags = array();
565 for ($i = 0; $i < sizeof($result_list); $i++
) {
566 if (eregi('^\* ([0-9]+).*FETCH.*FLAGS(.*)', $result_list[$i][0], $regs)
567 && isset($id2index[$regs[1]]) && count($id2index[$regs[1]])) {
568 $result_flags[$id2index[$regs[1]]] = explode(" ", trim(ereg_replace('[\\(\\)\\\\]', '', $regs[2])));
570 set_up_language($squirrelmail_language);
571 echo "<br><b><font color=$color[2]>\n" .
572 _("ERROR : Could not complete request.") .
574 _("Unknown response from IMAP server: ") .
575 $result_list[$i][0] . "</font><br>\n";
579 arsort($result_flags);
580 return $result_flags;
584 * Returns a message array with all the information about a message.
585 * See the documentation folder for more information about this array.
587 function sqimap_get_message ($imap_stream, $id, $mailbox) {
588 $header = sqimap_get_message_header($imap_stream, $id, $mailbox);
589 return sqimap_get_message_body($imap_stream, $header);
592 /* Wrapper function that reformats the header information. */
593 function sqimap_get_message_header ($imap_stream, $id, $mailbox) {
594 $read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[HEADER]", true, $response, $message);
595 $header = sqimap_get_header($imap_stream, $read);
597 $header->mailbox
= $mailbox;
601 /* Wrapper function that reformats the entity header information. */
602 function sqimap_get_ent_header ($imap_stream, $id, $mailbox, $ent) {
603 $read = sqimap_run_command ($imap_stream, "FETCH $id:$id BODY[$ent.HEADER]", true, $response, $message);
604 $header = sqimap_get_header($imap_stream, $read);
606 $header->mailbox
= $mailbox;
611 /* Wrapper function that returns entity headers for use by decodeMime */
613 function sqimap_get_entity_header ($imap_stream, &$read, &$type0, &$type1, &$bound, &$encoding, &$charset, &$filename) {
614 $header = sqimap_get_header($imap_stream, $read);
615 $type0 = $header["TYPE0"];
616 $type1 = $header["TYPE1"];
617 $bound = $header["BOUNDARY"];
618 $encoding = $header["ENCODING"];
619 $charset = $header["CHARSET"];
620 $filename = $header["FILENAME"];
623 /* Queries the IMAP server and gets all header information. */
624 function sqimap_get_header ($imap_stream, $read) {
625 global $where, $what;
627 $hdr = new msg_header();
630 /* Set up some defaults */
631 $hdr->type0
= "text";
632 $hdr->type1
= "plain";
633 $hdr->charset
= "us-ascii";
635 $read_fold = array();
637 while ($i < count($read)) {
638 /* unfold multi-line headers */
639 /* remember line for to, cc and bcc */
640 $read_fold[] = $read[$i];
642 while (($i +
1 < count($read)) && (strspn($read[$i +
1], "\t ") > 0) ) {
643 if ($read[$i+
1] != '') $read_fold[] = $read[$i+
1];
644 $read[$i +
1] = substr($read[$i], 0, -2) . ' ' . ltrim($read[$i+
1]);
645 array_splice($read, $i, 1);
649 $read_fold = array();
652 if (substr($read[$i], 0, 17) == "MIME-Version: 1.0") {
657 else if (substr(strtolower($read[$i]), 0, 26) == "content-transfer-encoding:") {
658 $hdr->encoding
= strtolower(trim(substr($read[$i], 26)));
662 else if (strtolower(substr($read[$i], 0, 13)) == "content-type:") {
663 $cont = strtolower(trim(substr($read[$i], 13)));
664 if (strpos($cont, ";")) {
665 $cont = substr($cont, 0, strpos($cont, ";"));
668 if (strpos($cont, "/")) {
669 $hdr->type0
= substr($cont, 0, strpos($cont, "/"));
670 $hdr->type1
= substr($cont, strpos($cont, "/")+
1);
677 while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) {
678 str_replace("\n", "", $line);
679 str_replace("\n", "", $read[$i]);
680 $line = "$line $read[$i]";
684 /* Detect the boundary of a multipart message */
685 if (eregi('boundary="([^"]+)"', $line, $regs)) {
686 $hdr->boundary
= $regs[1];
689 /* Detect the charset */
690 if (strpos(strtolower(trim($line)), "charset=")) {
691 $pos = strpos($line, "charset=") +
8;
692 $charset = trim($line);
693 if (strpos($line, ";", $pos) > 0) {
694 $charset = substr($charset, $pos, strpos($line, ";", $pos)-$pos);
696 $charset = substr($charset, $pos);
698 $charset = str_replace("\"", "", $charset);
699 $hdr->charset
= $charset;
701 $hdr->charset
= "us-ascii";
703 /* Detect type in case of multipart/related */
704 if (strpos(strtolower(trim($line)), "type=")) {
705 $pos = strpos($line, "type=") +
6;
707 if (strpos($line, ";", $pos) > 0) {
708 $type = substr($type, $pos, strpos($line, ";", $pos)-$pos);
710 $type = substr($type, $pos);
715 else if (strtolower(substr($read[$i], 0, 20)) == "content-disposition:") {
716 /* Add better content-disposition support */
719 while ( (substr(substr($read[$i], 0, strpos($read[$i], " ")), -1) != ":") && (trim($read[$i]) != "") && (trim($read[$i]) != ")")) {
720 str_replace("\n", "", $line);
721 str_replace("\n", "", $read[$i]);
722 $line = "$line $read[$i]";
726 /* Detects filename if any */
727 if (strpos(strtolower(trim($line)), "filename=")) {
728 $pos = strpos($line, "filename=") +
9;
730 if (strpos($line, " ", $pos) > 0) {
731 $name = substr($name, $pos, strpos($line, " ", $pos));
733 $name = substr($name, $pos);
735 $name = str_replace("\"", "", $name);
736 $hdr->filename
= $name;
740 else if (strtolower(substr($read[$i], 0, 9)) == "reply-to:") {
741 $hdr->replyto
= trim(substr($read[$i], 9, strlen($read[$i])));
745 else if (strtolower(substr($read[$i], 0, 5)) == "from:") {
746 $hdr->from
= trim(substr($read[$i], 5, strlen($read[$i]) - 6));
747 if (! isset($hdr->replyto
) ||
$hdr->replyto
== "") {
748 $hdr->replyto
= $hdr->from
;
753 else if (strtolower(substr($read[$i], 0, 5)) == "date:") {
754 $d = substr($read[$i], 5);
756 $d = strtr($d, array(' ' => ' '));
757 $d = explode(' ', $d);
758 $hdr->date
= getTimeStamp($d);
762 else if (strtolower(substr($read[$i], 0, 8)) == "subject:") {
763 $hdr->subject
= trim(substr($read[$i], 8, strlen($read[$i]) - 9));
764 if (strlen(Chop($hdr->subject
)) == 0) {
765 $hdr->subject
= _("(no subject)");
768 if ($where == 'SUBJECT') {
769 $hdr->subject = $what;
770 // $hdr->subject = eregi_replace($what, "<b>\\0</b>", $hdr->subject);
776 else if (strtolower(substr($read[$i], 0, 3)) == "cc:") {
778 if (isset($read_fold[0])) {
779 $hdr->cc
[$pos] = trim(substr($read_fold[0], 4));
781 while ($pos < count($read_fold)) {
782 $hdr->cc
[$pos] = trim($read_fold[$pos]);
786 $hdr->cc
[$pos] = trim(substr($read[$i], 4));
791 else if (strtolower(substr($read[$i], 0, 4)) == "bcc:") {
793 if (isset($read_fold[0])) {
794 $hdr->bcc
[$pos] = trim(substr($read_fold[0], 5));
796 while ($pos < count($read_fold)) {
797 $hdr->bcc
[$pos] = trim($read_fold[$pos]);
801 $hdr->bcc
[$pos] = trim(substr($read[$i], 5));
806 else if (strtolower(substr($read[$i], 0, 3)) == "to:") {
808 if (isset($read_fold[0])) {
809 $hdr->to
[$pos] = trim(substr($read_fold[0], 4));
811 while ($pos < count($read_fold)) {
812 $hdr->to
[$pos] = trim($read_fold[$pos]);
816 $hdr->to
[$pos] = trim(substr($read[$i], 4));
822 else if (strtolower(substr($read[$i], 0, 11)) == "message-id:") {
823 $hdr->message_id
= trim(substr($read[$i], 11));
826 /* ERROR CORRECTION */
827 else if (substr($read[$i], 0, 1) == ")") {
828 if (strlen(trim($hdr->subject
)) == 0) {
829 $hdr->subject
= _("(no subject)");
831 if (strlen(trim($hdr->from
)) == 0) {
832 $hdr->from
= _("(unknown sender)");
834 if (strlen(trim($hdr->date
)) == 0) {
840 else if (strtolower(substr($read[$i], 0, 11)) == "x-priority:") {
841 $hdr->priority
= trim(substr($read[$i], 11));
852 /* Returns the body of a message. */
853 function sqimap_get_message_body ($imap_stream, &$header) {
855 return decodeMime($imap_stream, $header);