I have created an html form in an html file.
<form action='index.html' method='post' id='contact_form'>
<!-- A regular html form -->
<input type='submit' id='send_message' class="button" value='Submit' />
</form>
The information then goes to a js file
$.post("send_comment.php",
$("#contact_form").serialize(),
function(result) { //Sends success or fail message back to the form
...
})
And should then be forwarded onwards to send_comment.php
if(mail($email_to,"A comment from" + $name,$message)){
echo 'sent'; // we are sending this text to the ajax request telling it that the mail is sent..
}else{
echo 'failed';
}
But, I don't get an email, even though mail() works on the server (I tried it). I am also not sure if the php even gets executed, since I tried adding a command to write "success" on a separate file just to test if the function works, but that never worked (It might be that I simply misprogrammed the test, but I don't think so).
Could somebody tell me what I did wrong?