I have an Ajax contact form included on my website and I'm handling it using mail.php, pretty standard procedure. My problem is that when I upload my site on 000webhost server for example the contact form sends the request and fails. The following jquery code works prefctly fine except that the email is not sent.
// Contact form handling
var url = 'the link to mail.php';
$('#contact-form').submit(function(event) {
event.preventDefault();
$('#dark-background').fadeIn(500);
$('#sending-message').fadeIn(1500, function() {
$.ajax({
type: "POST",
async: true,
url: url,
data: $("#contact-form").serialize()
})
.done(function (response) {
$('#sending-message').fadeOut(1500, function() {
$('#success-message').fadeIn(1500, function() {
$('#success-message').fadeOut(1500, function() {
$('#name').val("");
$('#email').val("");
$('#subject').val("");
$('#message').val("");
$('#dark-background').fadeOut();
});
});
});
})
.fail(function (data) {
$('#sending-message').fadeOut(1500, function() {
$('#failure-message').fadeIn(1500, function() {
$('#dark-background').fadeOut(2000, function(){
$('#failure-message').fadeOut(10000);
});
});
});
});
});
});
So on this server specifically its trying to send the request for some time and then I have specific callback functions to run as you can see depending on the outcome of the request.
On another server though, awardspace for example, it looks like the email is sent ( I get the message that the email is succesfully sent) but I don't receive anything. It's like the .fail function is not even running.
When i try the same code locally on the local server I built the code works perfectly fine and the email is sent.
The same code has 3 different outcomes... Is it a problem of these free servers? A problem on my coding? Do I forget something to include? Or do I miss something else?
Any help is appreciated and if you need more details please let me know