Php 如何验证Zend\Mail是否有打开的IMAP流?

Php 如何验证Zend\Mail是否有打开的IMAP流?,php,email,zend-mail,Php,Email,Zend Mail,我的主机公司不会在我们的web服务器上启用IMAP扩展,因此我无法使用IMAP功能。我试图使用Zend\Mail作为替代,但我无法确定本机IMAP函数与Zend\Mail函数的比例为1:1 我的部分脚本检查打开的IMAP流是否存在,如果存在,则关闭它,然后重新打开它。下面是我的php脚本如何使用IMAP函数实现的: function open($box='INBOX') { if ($this->mbox) $this->close(); $args

我的主机公司不会在我们的web服务器上启用IMAP扩展,因此我无法使用IMAP功能。我试图使用Zend\Mail作为替代,但我无法确定本机IMAP函数与Zend\Mail函数的比例为1:1

我的部分脚本检查打开的IMAP流是否存在,如果存在,则关闭它,然后重新打开它。下面是我的php脚本如何使用IMAP函数实现的:

function open($box='INBOX') {

    if ($this->mbox)
       $this->close();

    $args = array($this->srvstr.$this->mailbox_encode($box),
        $this->getUsername(), $this->getPassword());

    // Disable Kerberos and NTLM authentication if it happens to be
    // supported locally or remotely
    if (version_compare(PHP_VERSION, '5.3.2', '>='))
        $args += array(NULL, 0, array(
            'DISABLE_AUTHENTICATOR' => array('GSSAPI', 'NTLM')));

    $this->mbox = call_user_func_array('imap_open', $args);

    return $this->mbox;
}

function close($flag=CL_EXPUNGE) {
    imap_close($this->mbox, $flag);
}
如何使用Zend\Mail v2.2执行相同的操作

我尝试使用此代码,但它在状态为500时出错,只返回一个空白屏幕:

function open($box='INBOX') {

    if ($mail)
       $this->close();

    $args = array($this->srvstr.$this->mailbox_encode($box),
        $this->getUsername(), $this->getPassword());

    // Disable Kerberos and NTLM authentication if it happens to be
    // supported locally or remotely
    if (version_compare(PHP_VERSION, '5.3.2', '>='))
        $args += array(NULL, 0, array(
            'DISABLE_AUTHENTICATOR' => array('GSSAPI', 'NTLM')));

    $this->getProtocol();
    $protocol = $this->ht['protocol'];
    if ($protocol=="Imap")
        $mail = new Zend\Mail\Storage\Imap($args);
    else
        $mail = new Zend\Mail\Storage\Pop3($args);

    return $mail;
}

function close() {
    $mail->close();
    $mail='';
}

你的$args是错误的。这就是参数的编写方式:

$mail = new Zend_Mail_Storage_Pop3(array('host'     => 'localhost',
                                         'user'     => 'test',
                                         'password' => 'test'));