因业务中需要,我需要在php中执行QQ邮箱登录并拿回QQ邮箱中的邮件。服务器是DEBIAN服务器,环境是docker安装的php环境。在PHP中使用imap_open函数打开邮箱连接(记得在邮件设置中打开IMAP功能)。执行imap_open函数需要安装php_imap扩展,如果是windows下去除php_imap.dll扩展注释。本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
Fatal error: Uncaught Error: Call to undefined function imap_open() in D:\mail.php:10 Stack trace: #0 {main} thrown 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本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
但在Debian服务器中的docker环境下安装imap扩展还是遇到了一麻烦。直接进docker下php容器,开始安装。报错:configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
root@2123245efdr5:/var/www# docker-php-ext-install imap checking for IMAP Kerberos support... no checking for IMAP SSL support... no checking for utf8_mime2text signature... new checking for U8T_DECOMPOSE... configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
找了一下需要安装libc-client-devel模块,不过找了找发现这个模块名称只是适用于centos等,对Debian服务器没法安装,报错E: Unable to locate package libc-client-devel,因为根本不叫这名字。https://packages.debian.org/jessie/libc-client-dev 这里有说明这个包在debian下的完整名称。也可以使用apt-cache search libc-client搜索相关的包,发现需要使用ibc-client2007e-dev。本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
#在debian服务器下执行apt-get install libc-client-devel会报无法找到包文件 user@n123:~$ sudo apt-get install libc-client-devel Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package libc-client-devel #通过apt-cache search libc-client搜索查找 user@n123:~$ sudo apt-cache search libc-client libc-client2007e - c-client library for mail protocols - library files libc-client2007e-dev - c-client library for mail protocols - development files uw-mailutils - c-client support programs #需要使用如下 root@4ba2159bfcd0:/var/www# apt-get install libc-client2007e-dev Reading package lists... Done Building dependency tree Reading state information... Done ...... After this operation, 3816 kB of additional disk space will be used. Do you want to continue? [Y/n] y......本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
但仍然没有结束,安装时还遇到报错:configure: error: This c-client library is built with Kerberos support.Add --with-kerberos to your configure line. Check config.log for details.看提示是让我们在后面加一些选项,于是增加选项再执行安装.本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
root@4009lki4434dd:/var/www# docker-php-ext-install imap checking for utf8_mime2text signature... new checking for U8T_DECOMPOSE... checking for pam_start in -lpam... yes checking for crypt in -lcrypt... yes configure: error: This c-client library is built with Kerberos support. Add --with-kerberos to your configure line. Check config.log for details. #提示安装时添加--with-kerberos,增加选项再执行安装 root@4009lki4434dd:/var/www# docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap checking for crypt in -lcrypt... yes checking for krb5-config... no configure: error: Kerberos libraries not found. Check the path given to --with-kerberos (if no path is given, searches in /usr/kerberos, /usr/local and /usr )本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
选项是加了,但看提示是加的选项没有作用,因为默认的路径里找不到Kerberos libraries,此原因是因为没有安装Kerberos libraries。于是执行安装libkrb5-dev库,这一步成功之后再进行安装imap就成功了。本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
#安装libkrb5-dev库 root@4009lki4434dd:/var/www# apt-get install libkrb5-dev #最后执行安装imap安装成功: root@4009lki4434dd:/var/www# docker-php-ext-configure imap --with-kerberos --with-imap-ssl && docker-php-ext-install imap #如果已经安装了也可尝试使用下面的命令指定kerberos库的目录 docker-php-ext-configure imap --with-kerberos-inc=/usr/include --with-imap-ssl && docker-php-ext-install imap本文地址:http://www.04007.cn/article/805.html,未经许可,不得转载.
本文地址:http://www.04007.cn/article/805.html 未经许可,不得转载. 手机访问本页请扫描右下方二维码.
![]() |
![]() |
手机扫码直接打开本页面 |