SMTP RESTRICTION: How can i disable php mail function in CLOUDLINUX

This is the way I do it. 
It's the only method I've been able to figure out, and there might be a much better way to do it, but it works for me. 

1. Edit /etc/cl.selector/php.conf 

2. Add these lines right at the top of the file: 
Directive = sendmail_path
Default   = /bin/true
Type     = list
Range    = /usr/sbin/sendmail -t -i,/bin/true
Comment   = Switch to /bin/true to disable php mail
3. In the client's cpanel, change the sendmail path to /bin/true using "Select PHP Version > Switch to PHP Settings" 
He will no longer be able to send via php mail

The even better approach is to change this settings in global ini file through the following guideline:

[CageFS 6.0-33 or higher, LVE Manager 2.0-11.2 or higher]

There is /etc/cl.selector/global_php.ini file, where you can specify values of PHP options that should be applied for all Alt-PHP versions that are installed on a server. These settings will also be automatically applied to the new Alt-PHP versions that will be installed later.


# cat /etc/cl.selector/global_php.ini
[Global PHP Settings]
date.timezone = Europe/Warsaw
error_log = error_log
memory_limit = 192M

Sections are ignored. Only name of an option and a value have meaning.

When an option is absent in /etc/cl.selector/global_php.ini file, than it is not changed (applied) to php.ini for Alt-PHP versions.

date.timezone and error_log options are handled differently than the others. When these options are not in /etc/cl.selector/global_php.ini file, than values for the options will be taken from "native" php.ini file. And when the option is in php.ini for some Alt-PHP version already (and its value is not empty), than value from /etc/cl.selector/global_php.ini will be NOT applied.

To confirm changes (not affecting "date.timezone" and "error_log" options) please run:

/usr/sbin/cagefsctl --setup-cl-selector

To confirm changes (including "date.timezone" and "error_log" options) please run:

/usr/bin/selectorctl --apply-global-php-ini


/usr/sbin/cagefsctl --apply-global-php-ini

(two commands above work the same way).

If you don't want to change error_log, but want to change date.timezone, you can execute:

selectorctl --apply-global-php-ini date.timezone

Similarly, command "selectorctl --apply-global-php-ini error_log" applies error_log and all other options specified in /etc/cl.selector/global_php.ini file, except date.timezone.

So, you can specify 0, 1 or 2 parameters from the list: error_log, date.timezone.

Using --apply-global-php-ini without arguments applies all global PHP options including two above.


selectorctl --apply-global-php-ini error_log
selectorctl --apply-global-php-ini date.timezone
selectorctl --apply-global-php-ini date.timezone error_log

The latter command has the same effect as /usr/bin/selectorctl --apply-global-php-ini

Post a Comment