是否有php imap扩展的替代方案

是否有php imap扩展的替代方案,php,imap,Php,Imap,我的godaddy共享hosing服务将无法启用PHP的IMAP扩展。所以我陷入了困境: 是否有一个PHP函数来替换PHP中的IMAP特性 以下是错误: Fatal error: Call to undefined function imap_last_error() 以下是我遇到问题的示例代码: $mbox = imap_open ('{'.$email_host.':'.$email_port.'/pop3/novalidate-cert}INBOX', $email_username,

我的godaddy共享hosing服务将无法启用PHP的IMAP扩展。所以我陷入了困境:

是否有一个PHP函数来替换PHP中的IMAP特性

以下是错误:

Fatal error: Call to undefined function imap_last_error()
以下是我遇到问题的示例代码:

$mbox = imap_open ('{'.$email_host.':'.$email_port.'/pop3/novalidate-cert}INBOX', $email_username, $email_password) or die(imap_last_error());



        if(!$mbox){
            // send email letting them know bounce checking failed?
            // meh. later.
            echo 'Failed to connect when checking bounces.';
        }else{
            $MC = imap_check($mbox);
            $result = imap_fetch_overview($mbox,"1:{$MC->Nmsgs}",0);
            foreach ($result as $overview) {
                $this_subject = (string)$overview->subject;
                //echo "#{$overview->msgno} ({$overview->date}) - From: {$overview->from} <br> {$this_subject} <br>\n";
                $tmp_file = tempnam('/tmp/','newsletter_bounce');
                // TODO - tmp files for windows hosting.
                imap_savebody  ($mbox, $tmp_file, $overview->msgno);
                $body = file_get_contents($tmp_file);
                if(preg_match('/Message-ID:\s*<?Newsletter-(\d+)-(\d+)-([A-Fa-f0-9]{32})/imsU',$body,$matches)){
                    // we have a newsletter message id, check the hash and mark a bounce.
                    //"message_id" => "Newsletter-$send_id-$member_id-".md5("bounce check for $member_id in send $send_id"),
                    $send_id = (int)$matches[1];
                    $member_id = (int)$matches[2];
                    $provided_hash = trim($matches[3]);
                    $real_hash = md5("bounce check for $member_id in send $send_id");
                    if($provided_hash == $real_hash){
                        $sql = "UPDATE "._DB_PREFIX."newsletter_member SET `status` = 4, bounce_time = '".time()."' WHERE `member_id` = '".$member_id."' AND send_id = '".$send_id."' AND `status` = 3 LIMIT 1";
                        query($sql);
                        imap_delete($mbox, $overview->msgno);
                    }else{
                        // bad hash, report.
                    }
                }
                unlink($tmp_file);
            }
            imap_expunge($mbox);
            imap_close($mbox);
        }

    }
$mbox=imap_打开(“{.$email_主机”。:“.$email_端口”。/pop3/novalidate cert}收件箱“,$email_用户名,$email_密码)或死亡(imap_last_error());
如果(!$mbox){
//发送电子邮件让他们知道跳出检查失败?
//嗯,待会儿。
echo“检查反弹时无法连接”;
}否则{
$MC=imap\U支票($mbox);
$result=imap\u fetch\u overview($mbox,“1:{$MC->Nmsgs}”,0);
foreach($结果作为$overview){
$this_subject=(字符串)$overview->subject;
//echo“{$overview->msgno}({$overview->date})-From:{$overview->From}
{$this\u subject}
\n”; $tmp_file=tempnam('/tmp/','newsletter_bounce'); //TODO-windows主机的tmp文件。 imap_保存体($mbox,$tmp_文件,$overview->msgno); $body=file\u get\u contents($tmp\u file);
if(preg_match('/Message ID:\s*没有用PECL替换imap扩展。如果你敢的话,你可以用PHP编写一个,但这会非常无效。另一种方法是(假设他们对客户的请求免疫)将“GoDaddy”变成“GoAwayDaddy”并将ISP更改为不阻止此基本扩展的ISP。

此ISP适用于godaddy共享主机:

这一个也很有效:

function\uuu自动加载($class\u name){
包括$class_name.'.php';
}
包括_once'Zend/Mail/Storage/AbstractStorage.php';
包括“Zend/Mail/Storage/Pop3.php”;
$mail=new Zend\mail\Storage\Pop3(数组('host'=>“$host',
“用户”=>“$user”,
“密码”=>“$password”);
echo$mail->countMessages()“找到邮件\n”;
foreach($mail as$message){
echo“来自“{$message->from}”的邮件:{$message->subject}\n
”; echo$message->getContent()。“
”; }
IMAP作为一个内置函数已经有很长时间了,似乎没有人为它编写过外部类。不过老实说,禁止
IMAP.*
函数有点像是一个愚蠢的举动,这让我怀疑它们是否允许
fsockopen()
完全可以。你可能应该更换主机。除此之外,我还没有听到关于GoDaddy主机的任何好消息。zend的imap功能是否真的有效?比如zend_Mail_Storage_imap与GoDaddy?我浏览了互联网,甚至联系了GoDaddy,他们都没有任何线索。我很想听听你的回答!是的。你可能会的必须添加一个自动加载函数才能加载类。啊,谢谢你,我实际上刚刚运行了这个函数,因为Godaddy告诉我它不起作用!这与Godaddy共享主机一起起作用!谢谢你的帮助!@tman,如果它对你有帮助,你想过接受这个答案吗?@PapazzoKid我没有问这个问题:)
function __autoload($class_name) {
include $class_name . '.php';
}
 include_once 'Zend/Mail/Storage/AbstractStorage.php';
include_once 'Zend/Mail/Storage/Pop3.php';
$mail = new Zend\Mail\Storage\Pop3(array('host'     => '$host',
                                     'user'     => '$user',
                                     'password' => '$password'));

echo $mail->countMessages() . " messages found\n";
foreach ($mail as $message) {
   echo "Mail from '{$message->from}': {$message->subject}\n</br>";
   echo $message->getContent() . "</br>";
}