If you are running whm with cloudlinux it works:
php=`su – cpanel_username -s /bin/bash -c “php -v | grep ^PHP | cut -d”.” -f1-2″ | awk ‘{print $2}’`
su – cpanel_username -s /bin/bash -c “echo disable_functions=mail >> /etc/cl.php.d/alt-php$php/custom_php.ini”
/scripts/rebuildhttpdconf && service httpd restart