Introduction
You may use the following steps to disable the mail() function in PHP. The use of the mail() function allows a script to send messages without the need to use an existing email account and password.
Via WHM
1. Login to WHM as the root user
2. Navigate to: "Home »Software »MultiPHP INI Editor"
3. Click the "Editor Mode" tab
4. Select a version of PHP from the dropdown
5. Find the setting for disable_functions
6. Add the mail function to that setting. If there are no existing disabled functions, your setting would look like this:
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names.
; http://php.net/disable-functions
disable_functions = mail
7. Click the blue "Save" button in the upper right area of the editor
Via WHM with PHP-FPM enabled
- Navigate to "WHM» Software » MultiPHP Manager"
- Click "Manage Settings"
- Scroll down to "Disable Functions"
- Add mail to the "Disable Functions"
Via SSH or Terminal
1. Login to the server via SSH or Terminal
2. Use the following command to show a list of the php.ini configurations for each of your versions of PHP:
find /opt/cpanel/ea-php* -name "php.ini"
3. Open one of the php.ini files with the text editor of your choice
4. Edit the disable_functions option. If you only want to disable the mail function, it would look like this:
; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names.
; http://php.net/disable-functions
disable_functions = mail