Search code examples
phplaravelubuntunginximap

Fatal Error: Call to undefined function imap_open PHP


I have followed the steps below to enable IMAP and still things are not working.


    sudo apt-get install php5-imap
    sudo apt-get install php5-cli
    sudo php5enmod imap 
    service php5-fpm restart
    sudo service nginx restart


I can see the IMAP extension enabled under phpinfo and also can see the extension is loaded using command dpkg -l | grep php5-imap

Server: Linux and using nginx


Solution

  • This should be a comment, but I haven't got the reps for comment, so...

    1. Try to check your extension file, i.e. make sure that in /etc/php5/mods-enabled/imap.ini, the keyword extension=/path/to/imap.so is not commented (having ; or # as its beginning of line) and your /path/to/imap.so file exists.

    2. Try to check if you had multiple php-fpm services running. Use systemctl list-unit-files | grep php to check. If you had multiple php-fpm services, make sure you had installed imap extension to the correct php-fpm instance.