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!