This is what it looks like now:
PHP Code:
<script>
$("#notify").click(function(){
$.ajax({
type: "POST",
url: "/.../sendEmail.php",
data: "{ 'body': 'TEST', 'to': '...', 'from': '...', 'subject': 'Test' }",
dataType: "text",
statusCode: {
404: function() {
$("#notify").html("Could not contact server.");
},
500: function() {
$("#notify").html("A server-side error has occurred.");
}
},
error: function() {
$("#notify").html("A problem has occurred.");
},
success: function() {
$("#notify").html("Success!");
}
});
return false;
});
</script>
Still getting my Success-message. Still not receiving an email.
I have a feeling there's more to the error/success part, than I understand so far...
Any help would be greatly appreciated.
My sendEmail.php again:
PHP Code:
<?php
$mailTo = $_POST['to'];
$mailFrom = $_POST['from'];
$subject = $_POST['subject'];
$message = $_POST['body'];
mail($mailTo, $subject, $message, "From: ".$mailFrom);
?>
I really don't get it.