我的 godaddy 共享主机服务不会启用 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);
}
}
提前致谢!!