How can i disable php mail function? Print

  • php mailer, cpanel mail, php mail, cloudlinux, selection php version, php selector
  • 3

If your server is using cloudlinux, use the following method.

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

2. Add these lines right at the top of the file:

Directive = sendmail_path
Default   = /usr/sbin/sendmail -t -i
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

If your server is not cloudlinux, use the following method.

Create the separate php.ini file for your user and disable the mail function in that php.ini file,

disable_functions = mail, sendmail


Was this answer helpful?

« Back