[英]How do I verify that Zend\Mail has an open IMAP Stream?
我的托管公司不會在我們的Web服務器上啟用IMAP擴展,因此我無法使用IMAP功能。 我正在嘗試使用Zend \\ Mail作為替代,但是我無法用Zend \\ Mail函數映射出本機IMAP函數的一對一比率。
我的部分腳本會檢查是否存在一個打開的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'));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.