Imap works only on CLI

0

The PHP imap extension works only through the command line.

When calling the script from another place the return is:

 PHP Fatal error:  Uncaught Error: Call to undefined function imap_open()

When running a simple script in the cli the function runs correctly.

The server is PHP 7.1.15 running on a ubuntu16.04.

At the moment I am without clues of the cause or other information and without aim, to speak the truth. If you need information I publish, because I have no idea what else may be relevant.

Any help is welcome, thanks!

    
asked by anonymous 26.07.2018 / 01:06

1 answer

0

You should edit the php.ini of apache, the php.ini of the cli is different, create a file named phpinfo.php on the root of your http server, and add this:

<?php
phpinfo();

Execute like http://localhost/phpinfo.php see the part that says "Loaded Configuration File", as in the example:

In your PHP will display the correct path, then knowing the location edit the php.ini and then remove the ; of the line:

;extension=imap

Looking like this:

extension=imap
  

Until php7.1 the extensions were like this:

;extension=mysqli.so

Then save the edit and restart Apache (if it does not restart it does not work), terminal command is probably this (with sudo ):

sudo service apache2 restart
    
26.07.2018 / 01:36