有没有办法跟踪imap_open()的实时连接时间?我已经尝试了imap_timeout()但它只需要在php.ini中设置超时。我想在这里实现的是检查连接错误之前需要多长时间(例如错误的用户名)。
$mbox = imap_open($this->data['ServerName'], $this->data['UserName'], $this->data['PassWord']);
$time = time();
// $mbox = imap_open("{}INBOX", "", "");
$x = imap_timeout(IMAP_OPENTIMEOUT);
echo "<pre>";
var_dump($x);
echo "</pre>";
var_dump(time() - $time);
if ($hdr = imap_check($mbox)) {
echo "Num Messages: " . $hdr->Nmsgs ."\n\n<br><br>";
return $mbox;
} else {
// error_log("Connection Failed. Could not Connect to the Mail Server", 0);
// $this->sendErrorMail("Connection Failed. Could not Connect to the Mail Server");
die("Connection Failed. Could not Connect to the Mail Server");
}
答案 0 :(得分:0)
imap_timeout接受参数。你想要的是不变的IMAP_OPENTIMEOUT。
echo imap_timeout(IMAP_OPENTIMEOUT);