我遇到了同样的问题,看起来生成错误是因为 Exchange 服务器公布了它不支持的身份验证协议(http://vision.eng.shu.ac.uk/mmvlwiki/index.php/Exchange http://vision.eng.shu.ac.uk/mmvlwiki/index.php/Exchange)。这个问题似乎只发生在 Linux 服务器上,因为我在 Windows 机器上使用完全相同的代码没有问题。这是一个长期存在的问题,PHP 最近进行了修补(v 5.3.2),以允许您禁用某些身份验证协议(http://php.net/manual/en/function.imap-open.php http://php.net/manual/en/function.imap-open.php)。下面的代码对我来说间歇性地工作:
$this->inbox = imap_open("{server:993/imap/ssl/novalidate-cert}$inbox",
$username, $password, NULL, 1,
array('DISABLE_AUTHENTICATOR' => 'PLAIN')) or
die(var_dump(imap_errors()));
这也间歇性地起作用:
$this->inbox = imap_open("{server:993/imap/ssl/novalidate-cert}$inbox",
$username, $password, NULL, 1,
array('DISABLE_AUTHENTICATOR' => 'GSSAPI')) or
die(var_dump(imap_errors()));
所以我贫民窟操纵了这个,它似乎确实有效......尽管它有可能对我公司的交换服务器进行无限循环/DOS 攻击,但是/小心
希望有更好的解决方案,但这应该有所帮助:
$tryCnt = 0;
while(!is_resource($this->inbox)){
$this->inbox = imap_open("{server.com:993/imap/ssl/novalidate-cert}$inbox",
$username, $password, NULL, 1,
array('DISABLE_AUTHENTICATOR' => 'GSSAPI'));
$tryCnt ++;
if(!is_resource($this->inbox)){
$this->inbox = imap_open("{server.com:993/imap/ssl/novalidate-cert}$inbox",
$username, $password, NULL, 1,
array('DISABLE_AUTHENTICATOR' => 'PLAIN'));
$tryCnt ++;
}
if($tryCnt > 20){
echo "Cannot Connect To Exchange Server:<BR>";
die(var_dump(imap_errors()));
}
}