How do you disable email sent from PHP with PHP-FPM?

WebHostPro

Well-Known Member
PartnerNOC
Jul 28, 2002
1,725
27
328
LA, Costa RIca
cPanel Access Level
Root Administrator
Twitter
We have a server that wants to remove all email being sent from it. I disabled exim and IMAP but I can't find how to disable PHP email. I've scoured this forum for 20 minutes and give up lol.

Can someone post a cheat code of what file to edit and what to add to disable all PHP email when using PHP-FPM please?

I assume it's something to do with the file default_accounts_to_fpm

Maybe add this there?: disable_mail
 

WebHostPro

Well-Known Member
PartnerNOC
Jul 28, 2002
1,725
27
328
LA, Costa RIca
cPanel Access Level
Root Administrator
Twitter
I read that many times and it does not say anything about removing mail and the tutorial is confusing. Where is the examples?

I got as far as:
  1. /var/cpanel/ApachePHPFPM directory if it does not already exist.
  2. Create the /system_pool_defaults.yaml file.
In this file I'm supposed to add PHP-FPM pools.

Which it now says to go to this file for help : Configuration Values of PHP-FPM | cPanel & WHM Documentation

Which also does not have a examples. And it doesn't say anything about adding one for mail.

Can you even stop mail server wide or at least from PHP on the server?
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
I'm sorry I thought you understood how to disable PHP mail but just needed the instructions to do so with php-fpm. You need to add the following:

This uses:

Code:
disable_functions =
and the value for PHP mail is just "mail" so you'd just want to add mail to the appropriate file. The default for this with php-fpm as listed in the guide you linked looks like the following:

Code:
php_admin_value_disable_functions: exec,passthru,shell_exec,system
You'd change it to be:

Code:
php_admin_value_disable_functions: exec,mail,passthru,shell_exec,system
Then follow the instructions on changing this either globally or per domain as listed in the documentation I originally linked How to Manage Your php.ini Directives with PHP FPM | cPanel & WHM Documentation
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
in the default php.ini it looks like (only added this so you knew which section in the normal php.ini file it was) :

Code:
disable_functions =
If you want to change that or all of the PHP versions php.ini files in case you decide to disable php-fpm you'll make it look like:

Code:
disable_functions = mail


When modifying for php-fpm it looks like:
Code:
php_admin_value_disable_functions: exec,passthru,shell_exec,system
If you want to disable mail when running php-fpm you'll change the appropriate file to look like:
Code:
php_admin_value_disable_functions: exec,mail,passthru,shell_exec,system
 

cPanelLauren

Product Owner
Staff member
Nov 14, 2017
13,296
1,266
313
Houston
A bit more than that. You'll need to do the following (as noted in the documentation for making modifications both globally and per domain)

Rebuild the PHP-FPM configuration
Code:
usr/local/cpanel/scripts/php_fpm_config --rebuild
Restart PHP-FPM and Apache:
Code:
/usr/local/cpanel/scripts/restartsrv_apache_php_fpm
/usr/local/cpanel/scripts/restartsrv_httpd