In this case, I had to add PHP’s IMAP mail functions to an Amazon ec2 instance, but I will describe how to do it on Debian and Centos systems as well.
On Amazon’s most common LInux AMIs and similar systems using YUM just use the following at the command prompt from a command line shell:
sudo yum install php-imap
On Debian servers, use:
sudo apt_get install php5-imap
Then restart your httpd service. On amazon you can do so with
sudo service httpd restart