lundi 21 septembre 2015

Contact Form using PHPMailer not working

I made a contact form for my web and everything is ok with no errors but when I click on the send button, no email is sent to me. Here's the PHP:

<?php
require 'PHPMailer/PHPMailerAutoload.php';


$mail = new PHPMailer;


$to = "facundo_sb@icloud.com";


$nombre = $_POST['name'];



$telefono = $_POST['telefono'];
$correo = $_POST['correo'];
$asunto = $_POST['asunto'];
$mensaje = nl2br($_POST['mensaje']);


if ($nombre == "" || $telefono == "" || $correo == "" || $asunto == "" || $mensaje == ""):
    echo "<div class='alert alert-danger'>Debe rellenar todos los campos para enviar</div>";
else:

$mail->From = $correo;
$mail->addAddress($to);
$mail->Subject = $asunto;
$mail->isHtml(true);
$mail->Body = $mensaje; 
$mail->send();
endif;
?>

And the JavaScript:

$(document).ready(function(){
    $("#fcontacto").submit(function( event ){
        event.preventDefault();

        $.ajax({
            type: 'POST',
            url: 'send.php',
            data: $(this).serialize(),
            success: function(data){
                $("#respuesta").slideDown();
                $("#respuesta").html(data);
            }
        });

        return false;
    });
});

PD: I used PHPMailer as you can see in the code.




Aucun commentaire:

Enregistrer un commentaire