← ServerPilot Docs

How to Install the PHP IMAP Extension

The IMAP extension was removed from PHP core in PHP 8.4.

  • For PHP 8.3 and older, the IMAP extension is installed by default so you should not use the instructions below.
  • For PHP 8.4+, use the instructions below to install the IMAP extension.

Installing the IMAP Extension on PHP 8.4

To install the PHP IMAP extension on PHP 8.4, SSH in to your server as root and run the following commands:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config
sudo apt-get -y install libkrb5-dev libc-client-dev libssl-dev
yes '' | sudo pecl8.4-sp install imap

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

sudo bash -c "echo extension=imap.so > /etc/php8.4-sp/conf.d/imap.ini"
sudo service php8.4-fpm-sp restart

Using the PHP IMAP Extension

See the documentation for the PHP IMAP extension for usage information.

Uninstalling the IMAP Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/php8.4-sp/conf.d/imap.ini
sudo pecl8.4-sp uninstall imap

Next, restart PHP-FPM with the command:

sudo service php8.4-fpm-sp restart
Last updated: October 28, 2024

Launch your first site in 5 minutes