首页 > 解决方案 > imap_open 很长的延迟

问题描述

我们使用以下代码通过 SSL 连接到 IMAP:

imap_timeout(IMAP_OPENTIMEOUT, 5);
imap_timeout(IMAP_READTIMEOUT, 5);
imap_timeout(IMAP_WRITETIMEOUT, 5);
imap_timeout(IMAP_CLOSETIMEOUT, 5);

$connection = null;
try {
    $connection = imap_open('{'.$host.':'.$port.'/service='.$service.$crypt.'/novalidate-cert}', $user, $pass, OP_SILENT, 1, array('DISABLE_AUTHENTICATOR' => 'PLAIN'));
} catch (Exception $e) {
    // Errors logged in a summary below
}

这通常没有任何问题。但是,有时它会在 imap_open 上挂起超过 800 秒。它返回的错误是:

TLS\/SSL failure for imap.xxx.net: SSL negotiation failed

如何确保 imap_open 不会等待这么久?

标签: phpimap

解决方案


推荐阅读