Wednesday, May 16, 2012

ajaxified php mail not working

I'm running on a MAC and I am trying to use php mail with ajax implementation.



I have simplified my code to the point that it was reduced to strings:



In my .js file :



function ajaxMail2() {



$('#sending').show();


$.ajax({

type:'POST',
url:'ajax/mail.php',

success:function(data, status) {
$('#sending').hide();
$('#success').fadeIn(1000,function() {
//$(this).delay(200).fadeOut(1000);
});
},

error:function(data, status, e) {
$('#sending').hide();
$('#fail').fadeIn(1000,function() {
$(this).delay(200).fadeOut(1000);
});
}

});


}


and on my .php file :



<?php



$to = 'foo@gmail.com';
mail($to,'test','test');



?>


When the form is submitted, it goes to the success function but no email was sent to $to. Any ideas?





No comments:

Post a Comment