Hello everyone. I fixed this problem after 3 hours of diging the code :). Basically, the problem is in "fetchheaders" function. At some point script queries IMAP and looks for result like "* blah FETCH blah blah". And after it automatically assumes that server will send headers back. It's true. BUT for unseen message server sends back ONE more reposnse "* blah FETCH (FLAGS (\Seen))" which is NOT followed by any other data related to this FETCH. if everything's ok, server sends "blah OK FETCH completed".
Quick trace: C -> S "blah FETCH blah (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID)]) S -> C "* blah FETCH blah blah" // first message S -> C "date: blah" -- " -- " -- S -> C "from: blah" S -> C ")" //<- end of headers
C -> S "blah FETCH blah (BODY.PEEK[HEADER.FIELDS (DATE FROM TO SUBJECT REPLY-TO IN-REPLY-TO CC CONTENT-TRANSFER-ENCODING CONTENT-TYPE MESSAGE-ID)]) S -> C "* blah FETCH blah blah" // second message (unseen) S -> C "date: blah" -- " -- " -- S -> C "from: blah" S -> C ")" //<- end of headers S -> C "* blah FETCH (FLAGS (\Seen))"
// At this point if($a[0] == "*" && $a[2] == "FETCH") IS true. Script goes inside the ifbody and attempes to read headers with are supposed to end with ")", HOWEVER it gets "fh0 OK FETCH completed" which means FETCH was successful, MOVE ON :). BUT no this time, we are waiting and waiting and ... waiting for ")", which never comes :).
Did anyone understand what I wrote here ?
And here quick fix (I think in the release it should be done a little different):
do{ $line=chop(iil_ReadLine($fp, 200)); $a=explode(" ", $line); if (($line[0]=="*") && ($a[2]=="FETCH")){
<<<!!! SKIP !!!>>>
do{
$line = chop(iil_ReadLine($fp, 300),"\r\n");
if (ord($line[0])<=32)
$lines[$i].=(empty($lines[$i])?"":"\n").trim(chop($line)); else{ $i++; $lines[$i] = trim(chop($line)); } ! }while($line[0]!=")" && strncmp($line, $key, strlen($key)));
if(strncmp($line, $key, strlen($key)))
{
//process header, fill iilBasicHeader obj.
// initialize
if (is_array($headers)){
reset($headers);
while ( list($k, $bar) = each($headers) ) $headers[$k] = "";
}
<<<!!! SKIP !!!>>>
$result[$id]->messageID = $messageID;
}
else
{
$a=explode(" ", $line);
}
}
}while(strcmp($a[0], $key)!=0);Right now, everything works fine. Good luck.
P.S. is there an archive of this mailing list ? Thanks !
Express yourself instantly with MSN Messenger! Download today - it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/