make([ 'host' => $host, 'port' => $port, 'encryption' => $enc, 'validate_cert' => false, 'username' => $user, 'password' => $pass, 'protocol' => 'imap' ]); // cheat as real function fails with bad return type. // $client->connection->setConnectionTimeout(60); //$this->connection->setConnectionTimeout($timeout); //Connect to the IMAP Server try { $client->connect(); } catch (Exception $e) { echo "Connect failed for some reason\n"; echo $e->getMessage(); echo "\n"; return $ret; } $client->openFolder($folder,false); // NOT USING RANGE YET!! $msgs = $client->connection->fetch(["FLAGS","INTERNALDATE","UID"],explode(",",$range),null,IMAP::ST_MSGN); foreach ($msgs as $m) { // echo var_dump($m); $x = new MINFO(); $x->uid = intval($m["UID"]); $x->udate = cleanupDate($m["INTERNALDATE"]); $x->seen = 0; $x->recent = 0; $x->deleted = 0; $x->answered = 0; $x->flagged = 0; foreach ($m["FLAGS"] as $w) { if ($w=="\Seen") $x->seen = 1; if ($w=="\Recent") $x->recent = 1; if ($w=="\Deleted") $x->deleted = 1; if ($w=="\Answered") $x->answered = 1; if ($w=="\Flagged") $x->flagged = 1; } array_push($ret,$x); } $client->disconnect(); return $ret; } ?>