Hello,
I am having trouble sending a mail using jQuery and PHP.
The problem is that I don't receive the email which is supposed to be send after clicking the send button. (no really :-p)
Firebug and webdevelopment console in firefox 5 does not give an error anywhere.
I think it is in my PHP file, since after the ajax post in jQuery, it does execute the success function, so I guess that it does reach the php page.
This is the code I am using:
Jquery:- $('#contact-versturen').live('click', function(event)
{
event.preventDefault();
contactNaam = $('#contact-naam').val();
contactEmail = $('#contact-email').val();
contactBericht = $('#contact-bericht').val();
if(contactNaam != '' && contactEmail != '' && contactBericht != '')
{
dataString = $('#contact-form').serialize();
alert(dataString);
sendMail(dataString);
}
else
{
alert('Niet alles is ingevuld!');
}
});
function sendMail(dataString)
{
$.ajax({
type: 'POST',
url: 'includes/sendMail.php',
data: dataString,
success: sendSuccesfull
});
}
function sendSuccesfull()
{
$('#contact-form').animate({
opacity: 0
}, 1000, function()
{
$('#contact-form').remove();
$('#form-container').css({ opacity: 0 });
$('#form-container').append('<div id="send-succesfull"><p>Bericht is succesvol verstuurd.</p><p>Er wordt zo snel mogelijk contact met u opgenomen.</p></div>');
$('#form-container').animate({
opacity: 1
}, 1000);
});
}
PHP:- <?php
$ontvanger = "********@****.com";
$onderwerp = "Iemand probeert contact via de website op te nemen";
$verstuurder = "Van: " . $_POST['email'] . "\n";
$bericht = "Dit bericht werd op " . date("d-m-Y") . " om " . date("H:i") . " uur verzonden.\n";
$bericht .= "De volgende persoon vulde het contact formulier in:\n\n";
$bericht .= "Naam: " . $_POST['naam'] . "\n";
$bericht .= "E-mailadres: " . $_POST['email'] . "\n\n";
$bericht .= "Bericht:\n";
$bericht .= $_POST['bericht'];
$bericht .= "\n\n !----- Einde van het contact bericht -----!";
mail($ontvanger, $onderwerp, $bericht, $verstuurder);
?>
I hope you guys can help me.
Thanks in advance,
Mark