PHP Mail() function not working in cpanel hosting
13,889
Your code seems correct, but most hosts block the mail function by default and/or prevent the user nobody from sending emails.
In Tweak Settings, try turning off the option "Prevent 'nobody' from sending mail".
In the PHP Configuration Editor (in advanced mode) check if the mail function is listed in the disable_functions directive.
If none of that work, check if the exim is up and running and if the sendmail_path in php.ini is correct.
Author by
Vishnu Sharma
Updated on September 14, 2022Comments
-
Vishnu Sharma over 1 year
The PHP
mail()
function is not working from my cpanel.My cpanel ports are all open and by default the email ID is also set in cpanel.
MY code
$to = "[email protected]"; $subject = "My subject"; $txt = "Hello world!"; $headers = "From: [email protected]" ; mail($to,$subject,$txt,$headers);
-
Amit Merchant over 6 yearsShow me your code.
-
Vishnu Sharma over 6 yearsMY code
code
$to = "[email protected]"; $subject = "My subject"; $txt = "Hello world!"; $headers = "From: [email protected]" ; mail($to,$subject,$txt,$headers);
-