This is my PHP script:
<?php
require_once 'PHPMailerAutoload.php';
$mailApp = new PHPMailer();
$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];
$mailApp->From = $email;
$mailApp->FromName = $name;
$mailApp->Subject = 'Contacto de http://profile.cv.hsoto.me';
$mailApp->Body = $message;
$mailApp->AddAddress('hectorsoto@balamtech.com', 'Hector Soto');
if($mailApp->Send()){
echo '<div class="alert alert-success text-center">Su mensaje fue enviado. Gracias por ponerse en contacto conmigo.</div>';
} else {
echo '<div class="alert alert-danger text-center">El mensaje no se pudo enviar. Por favor intente de nuevo o mándelo al <a href="mailto:hectorsoto@balamtech.com">hacer click aquí</a>.</div>';
}
?>
Pretty straightforward, it sends an email.
This is my jquery script:
$('#cmdSendMessage').on('click', function(e){
e.preventDefault();
var message, name, email, error = "";
email = $('#uemail').val();
message = $('#umessage').val();
name = $('#uname').val();
if(email == "" || message == "" || name == ""){
error = '<div class="alert alert-danger text-center">Uno o más campos están vacíos.</div>';
$('#error-spot').append(error);
}else if(!validateEmail(email)){
error = '<div class="alert alert-danger text-center">El correo no es válido, su formato es incorrecto.</div>';
$('#error-spot').append(error);
} else{
$.post('sendMail.php',
{name : name, message : message, email : email}
).done(
function(data){
$('#error-spot').append(data);
}).fail(
function(data){
$('#error-spot').append('<div class="alert alert-danger text-center">Hubo un error y no se pudo mandar el correo. Hacerlo manualmente al <a href="mailto:hectorsoto@balamtech.com">hectorsoto@balamtech.com</a></div>');
})
}
});
It processes data and sends the email, however, it thorws an error:
Any ideas why this might be happening?
EDIT:
When looking on the network tab on chrome, they are actually sent:
Which makes this even more weird that they are not being captured on the other side.