致命错误:在PHP中调用未定义的函数imap_open() [英] Fatal error: Call to undefined function imap_open() in PHP

查看:627
本文介绍了致命错误:在PHP中调用未定义的函数imap_open()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过本地主机访问我的Gmail帐户.但是,我得到了答复:

I am trying to access my gmail account through my localhost. However, I am getting the response:

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

Fatal error: Call to undefined function imap_open()

这是我的代码:

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'myid@gmail.com';
$password = 'mypassword';

/* try to connect */
$inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' .imap_last_error());

推荐答案

很简单,在您的PHP安装中未激活IMAP扩展.默认未启用该功能.如果本地安装在Windows上运行XAMPP,则必须按照 XAMPP常见问题:

Simple enough, the IMAP extension is not activated in your PHP installation. It is not enabled by default. If your local installation is running XAMPP on Windows, you have to enable it as described in the XAMPP FAQ:

IMAP对PHP的支持在哪里?

Where is the IMAP support for PHP?

默认情况下,在XAMPP中停用了对PHP的IMAP支持,因为 某些房屋存在一些神秘的初始化错误 Windows 98之类的版本.使用NT系统的人可以打开该文件 "\xampp\php\php.ini"通过删除来激活php扩展 在行";extension=php_imap.dll"处开始的分号.应该: extension=php_imap.dll

As default, the IMAP support for PHP is deactivated in XAMPP, because there were some mysterious initialization errors with some home versions like Windows 98. Who works with NT systems, can open the file "\xampp\php\php.ini" to active the php exstension by removing the beginning semicolon at the line ";extension=php_imap.dll". Should be: extension=php_imap.dll

现在重新启动Apache,并且IMAP应该可以工作.您可以使用相同的步骤 对于每个扩展名,默认情况下未启用 配置.

Now restart Apache and IMAP should work. You can use the same steps for every extension, which is not enabled in the default configuration.

这篇关于致命错误:在PHP中调用未定义的函数imap_open()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆