Imap works only on CLI

Asked

Viewed 73 times

0

The PHP imap extension works only via 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 cli the function runs correctly.

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

Right now I’m running out of clues to the cause or other information and I’m drifting, to tell you the truth. If you need information, I’ll publish it, because I have no idea what else might be relevant.

Any help is welcome, thank you!

1 answer

0

You must edit the php.ini apache, the php.ini of cli is different, create a file called phpinfo.php on your http server’s Rais, and add this:

<?php
phpinfo();

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

exemplo de caminho do php.ini no php7.2 em sistemas ubuntu

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

;extension=imap

Thus remaining:

extension=imap

Until php7.1 the Extensions were so:

;extension=mysqli.so

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

sudo service apache2 restart
  • Thanks William, I followed the steps but the problem persisted. I fixed the PHP version in the post, is 7.1. This server has several installed versions. This server has added ini files in conf. d: /conf. d/20-imap.ini E inside the file has: Extension=imap.so On the return of the phpinfo() function this file is listed in Additional . ini files Parsed.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.