Symptoms
-
Cannot send mail via PHP script or cannot execute curl request via PHP script;
-
The following error can be found in the domain's error log in Domains > example.com > Logs, alternatively, this error might be reflected instead of domain's content:
Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined function mail() in /var/www/vhosts/example.com/httpdocs/test.php:3nStack trace:n#0 {main}n thrown in /var/www/vhosts/example.com/httpdocs/test.php on line 3'
Cause
PHP function xxx()
is disabled in php.ini
.
Resolution
Warning: These steps ONLY apply to PHP-FastCGI, they do NOT apply for PHP-FPM, because for FPM disabled_functions directives will get overwritten by the Global PHP Configuration.
Configuring disable_functions in Plesk interface for a particular domain:
-
Go to Domains > example.com > PHP Settings, remove everything from
disable_function
section > OK:In case there is no
disable_function
section add the following line in Additional configuration directives field in Domains > example.com > PHP Settings > Additional directives to override mainphp.ini
directives:disable_functions=""
Note: For the server-wide ways, check what PHP handler is enabled in Plesk > Home > Domains > example.com > PHP Settings . Let it be PHP 8.1.
Configuring disable_functions in Plesk interface server-wide:
-
Go to Tools & Settings > PHP Settings > <PHP handler version> > php.ini;
-
Find
disable_functions
and removexxx
from the list. Press OK to save changes.
Configuring disable_functions server-wide via SSH:
-
Connect to the server via SSH.
-
Check that
disable_functions
is enabled in the php.ini of the handler in use:# grep xxx /opt/plesk/php/8.1/etc/php.ini | grep disable
disable_functions = xxx,mail,curl_multi_exec,dl,exec,passthru,proc_open,proc_close,shell_exec,show_source,symlink,system,show_source, popen -
Open
php.ini
file with text editor, i.e. vi editor:# vi /opt/plesk/php/8.1/etc/php.ini
-
Find the line with
disable_functions
and deletexxx
function from the list of disabled functions. -
Restart PHP service:
# service plesk-php81-fpm restart