Fairly straightforward but I always forget:
sudo apt-get install php-imap sudo phpenmod imap sudo nano/etc/php/7.0/apache2/php.ini
Add imap.so to the loaded extensions:
;extension=php_xsl.dll ... extension=imap.so
Then reloadĀ Apache:
sudo systemctl reload apache2
If you want to see a great PHP IMAP application with source code for managing your email, check out Simplify Email.