How to completely disable email on a cPanel server.
Two main processes run email on a cPanel server.
- EXIM - Used for email clients, pop3, and imap.
- PHP - Used for website forms mostly.
To disable exim server-wide, you just need to go to the services section in your WHM, and un-click: exim, imap, mailman, pop3, and spam assassin.
To disable PHP mail server-wide when using PHP-FPM, you have to go into the root of the server and do this:
Add /var/cpanel/ApachePHPFPM directory if it does not already exist.
Create the /system_pool_defaults.yaml file.
In the new /system_pool_defaults.yaml add this code:
php_admin_value_disable_functions: exec,mail,passthru,shell_exec,system