Friday 11 March 2016

PHP can send email from command line but not browser



I have a form set up at my homepage. When someone submits the form, it redirects them to a php script that sends me the form. The only issue is, the form won't send me anything when I use the browser. I have a script running on the same server that when I execute from the command line, sends an email immediately. When I go to the page in a browser, it gives a confirmation message, but won't send anything. What's happening? PHP is using MSMTP to send email if that helps. I believe apache is running as root (I know that's bad). How do I check?



Here's the code if anyone wants it:



    ini_set( 'display_errors', 1 );

error_reporting( E_ALL );
$from = "mailbot@prototypexenon.tech";
$to = "";
$subject = "PHP Mail Test script";
$message = "This is a test to check the PHP Mail functionality";
$headers = "From:" . $from;
mail($to,$subject,$message, $headers);
echo "Test email sent";
?>



EDIT: Apparently new-server-owner was smart enough to not let apache run as root. All fixed now. Thanks @EdHeal


Answer



Apparently new-server-owner was smart enough to not let apache run as root. All fixed now. Thanks @EdHeal


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...