The imap extension of PHP helps you to work with the IMAP protocol, also with work with NNTP, POP3 and local mailbox access methods.
Following command will help you to install on Ubuntu.
sudo apt-get install php5-imap
After installed, enable php5-imap
sudo php5enmod imap
Last thing is RESTART
sudo service apache2 restart
Do you want to verify?
php -m|grep imap
Create a file in web directory name it info.php
vi info.php or nano info.php
Paste below given code in info.php
<?php phpinfo(); ?>
Open your site with /info.php
For example: www.yourdomain.com/info.php