Skip to main content

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

Comments

8 comments

  • cPanelLauren
    Hello, You'd just need to follow the instructions for modifying .ini values here: How to Manage Your php.ini Directives with PHP FPM | cPanel & WHM Documentation
    0
  • WebHostPro
    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:
    • /var/cpanel/ApachePHPFPM directory if it does not already exist.
    • 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?
    0
  • cPanelLauren
    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: 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: php_admin_value_disable_functions: exec,passthru,shell_exec,system
    You'd change it to be: 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
    0
  • WebHostPro
    I should of mentioned I was past that, sorry. This is perfect, thank you!
    0
  • WebHostPro
    So the file should like this right: disable_functions = php_admin_value_disable_functions: exec,mail,passthru,shell_exec,system
    0
  • cPanelLauren
    in the default php.ini it looks like (only added this so you knew which section in the normal php.ini file it was) : 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: disable_functions = mail
    When modifying for php-fpm it looks like: 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: php_admin_value_disable_functions: exec,mail,passthru,shell_exec,system
    0
  • WebHostPro
    This is for a server that uses PHPFPM So I add to the file: /var/cpanel/ApachePHPFPM/system_pool_defaults.yaml php_admin_value_disable_functions: exec,mail,passthru,shell_exec,system
    Then reboot PHPFPM Correct?
    0
  • cPanelLauren
    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 usr/local/cpanel/scripts/php_fpm_config --rebuild
    Restart PHP-FPM and Apache: /usr/local/cpanel/scripts/restartsrv_apache_php_fpm /usr/local/cpanel/scripts/restartsrv_httpd
    0

Please sign in to leave a comment.