Disable PHP mail function in CWP


This article is based on Sandeep’s article at AlphaGNU.
Disable PHP mail function in CWP – Control webpanel – CWP – Control WEB Panel – AlphaGNU

It is meant to be a backup, just in case the other site gives an error.


INTRODUCTION

In this tutorial we’ll learn how to disable php mail() function in CWP to block the users to be able to send spam emails or infected emails from php mail function. This will force users to use SMTP based email sending structure which is more secure and easily controllable upon the amount of mails they are sending i.e. you can add quota hourly basis in packages.


READ ME FIRST

This article is provided as a courtesy.
Installing, configuring, and troubleshooting third-party applications is outside the scope of basic support provided by Starburst Services.

We are not liable for any damages and/or data loss.


REQUIRMENTS

  • SSH credentials or File Manager access Logged In as Root

Run this below commands to Disable PHP mail function completely :

If using PHP switcher:

echo "disable_functions = mail" > /usr/local/php/php.d/disabled_function.ini

If using PHP-CGI selector:

echo "disable_functions = mail" > /opt/alt/php53/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php54/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php55/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php56/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php70/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php71/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php72/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php73/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php74/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php80/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php81/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php82/usr/php/php.d/disabled_function.ini
echo "disable_functions = mail" > /opt/alt/php83/usr/php/php.d/disabled_function.ini

If using PHP_FPM Selector:

echo "disable_functions = mail" > /opt/alt/php-fpm53/usr/php/php.d/disabled_function.ini && service php-fpm53 restart
echo "disable_functions = mail" > /opt/alt/php-fpm54/usr/php/php.d/disabled_function.ini && service php-fpm54 restart
echo "disable_functions = mail" > /opt/alt/php-fpm55/usr/php/php.d/disabled_function.ini && service php-fpm55 restart
echo "disable_functions = mail" > /opt/alt/php-fpm56/usr/php/php.d/disabled_function.ini && service php-fpm56 restart
echo "disable_functions = mail" > /opt/alt/php-fpm70/usr/php/php.d/disabled_function.ini && service php-fpm70 restart
echo "disable_functions = mail" > /opt/alt/php-fpm71/usr/php/php.d/disabled_function.ini && service php-fpm71 restart
echo "disable_functions = mail" > /opt/alt/php-fpm72/usr/php/php.d/disabled_function.ini && service php-fpm72 restart
echo "disable_functions = mail" > /opt/alt/php-fpm73/usr/php/php.d/disabled_function.ini && service php-fpm73 restart
echo "disable_functions = mail" > /opt/alt/php-fpm74/usr/php/php.d/disabled_function.ini && service php-fpm74 restart
echo "disable_functions = mail" > /opt/alt/php-fpm80/usr/php/php.d/disabled_function.ini && service php-fpm80 restart
echo "disable_functions = mail" > /opt/alt/php-fpm81/usr/php/php.d/disabled_function.ini && service php-fpm81 restart
echo "disable_functions = mail" > /opt/alt/php-fpm82/usr/php/php.d/disabled_function.ini && service php-fpm82 restart
echo "disable_functions = mail" > /opt/alt/php-fpm83/usr/php/php.d/disabled_function.ini && service php-fpm83 restart

Thanks for learning with Starburst Services.

Make sure to visit AlphaGNU at: https://www.alphagnu.com/

Learn more about our services


KB Article Created: 2024-09-01

people found this article helpful. What about you?