I'm trying to send an email with PHPMailer, but everytime I press to send, the page turns white. I tried to search in the error_log but nothing appeared inside. By the way, I'm using ajax, all the plugins are included and working.
This is the code I have:
$.ajax({
type: "POST",
url: "cod_ajax/enviar_email.php",
data: "nome="+nome+"&last="+last+"&email="+email+"&assunto="+assunto+"&texto="+texto,
success:function(e){
document.write(e);
$("#envia_email").prop("disabled", true);
setInterval(function(){
$("#envia_email").html("Email Enviado com sucesso! Recarregue a página para enviar outro!");
}, 2000);
$(".erros").fadeOut(0);
$("#name").val("");
$("#last").val("");
$("#email").val("");
$("#assunto").val("");
$("#texto").val("");
}
})
All variables are right, nothing is empty and receive well the information. This is my ajax file:
if(isset($_POST['name'])){
$nome=$_POST['nome'];
$last=$_POST['last'];
$email=$_POST['email'];
$assunto=$_POST['assunto'];
$texto=$_POST['texto'];
require '../mail/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->setFrom('b_daniel_18@hotmail.com');
$mail->addAddress('b_sem_l@hotmail.com');
$mail->Subject = 'First PHPMailer Message';
$mail->Body = 'Hi! This is my first e-mail sent through PHPMailer.';
if(!$mail->send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
}
I didn't use the variables because it didn't work so I tried adding information manually, still didn't work.
UPDATE
Removed the if(isset($_POST['name']))
and I can see the errors now. It doesn't send, appears Mailer error: Could not instantiate mail function.