The IMAP extension was removed from PHP core in 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
See the documentation for the PHP IMAP extension for usage information.
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