yum -y install pam-devel
Debian
apt-get install libc-client-dev
Once pre-install is done for your OS, run the following:
cd /root
wget files.directadmin.com/services/all/imap_php.sh
chmod 755 imap_php.sh
./imap_php.sh
DirectAdmin
cd /usr/local/directadmin/custombuild
./build update
./build set_php imap yes
./build php_imap