致命错误:调用未定义的函数imap_open()

时间:2011-07-26 21:33:04

标签: php gmail-imap

正确的天才,我一整天都在这个liturary,现在我很绝望!情况就是这样。我正在使用免费的虚拟主机,每当我尝试使用imap_open这个消息出现时:致命错误:调用未定义的函数imap_open()。我似乎没有任何访问服务器设置的权限,看起来php没有安装imap模块,即使我直接问我联系我的提供商(web000):你支持imap功能吗?他回答是的。我确实给他发了一封邮件,上面写着错误信息,然后告诉他这是怎么回事。还没有收到他的消息。无论如何,无论如何,我可以访问我的gmail内容,假设imap函数未定义,是否有任何库可以下载以获得此功能? 谢谢你的时间。

1 个答案:

答案 0 :(得分:3)

您可以使用Zend_Mail来读取不需要imap扩展名的imap邮箱,因为它是IMAP协议的纯PHP实现(它使用套接字连接到邮件服务器)。

在您的主机上使用Zend Framework没有特殊要求。只需下载包,解压缩并上传到您的主机。我建议您the minimal edition可以运行以下代码。

要连接到Gmail帐户,您可以从此代码开始,它将连接到您的帐户,获取存储在服务器上的第一条消息并输出其主题,然后您可以展开它。

<?
// Ensure Zend folder is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    '/home/tachyon/public_html/zend/library/',
     get_include_path(),
)));

// require the ZF autoloader file if you have it in your include path
require_once 'Zend/Loader/Autoloader.php';
// if ZF is not in your path you can specify the full path
// otherwise if it's in a subdir (most likely if you're on a web hosting)
// you can do something like this
//require_once dirname(__FILE__) . '/Zend/Loader/AutoLoader.php';

// laod the autoloader so you don't need to require any ZF file
Zend_Loader_Autoloader::getInstance();

// connecting with Imap to gmail
$mail = new Zend_Mail_Storage_Imap(
    array(
        'host'     => 'imap.gmail.com',
        'port'     => '993',
        'ssl'      => true,
        'user'     => 'user@gmail.com',
        'password' => 'secret',
    )
);

// get the message object
$message = $mail->getMessage(1);
// output subject of message
echo $message->subject . "\n";
// dump message headers
Zend_Debug::dump($message->getHeaders());

我亲自使用我的Gmail帐户对此进行了测试,因此它正在运行代码。