0

Hi i got this code no error in console but email dont come on my email. Php code :

    <?php
    require ('src/PHPMailer.php');
use \PHPMailer\PHPMailer\PHPMailer;
use \PHPMailer\PHPMailer\Exception;

     function mail_attachment($from ,$to, $subject, $message){
        $email = new PHPMailer();
        $email->From = $from;
        $email->FromName = $from;
        $email->Subject = $subject;
        $email->Body = $message;
    $email->addAddress($to);
    return $email->send();
}

//Sending
$email = 'XXX';

mail_attachment('XXX', $email, 'New email', 'New email');

header("Location: index.html");
?>

ajax:

   $(document).ready(function(){
    $(".submitform").on("click",function() {
        var data = "XXX";
        $.ajax({
            url: 'send.php',
            type: 'POST',
            data: {
                data: data
            }
        });
    });
});

<button type="submit" class="btn btn-secondary text-danger submitform">SEND</button>

What I am doing bad ..? I am php noob so if you have any idea i will be grateful. Thank you.

lukas5895
  • 1
  • 2
  • you dont use any variables from the ajax call –  Jan 25 '18 at 21:57
  • `header("Location: index.html");` makes no sense in an ajax call. if new avoid ajax until you understand the basics –  Jan 25 '18 at 21:58

0 Answers0