0

I'm struggling with sending email from the code, and don't understand where can be the problem but I'm not getting any email :( also from the DEV tab of the browser, I'm getting 200 OK which should work, but it's not. I tried different email providers but still no luck.

This is my HTML code:

        <form action="https://example.com/send.php" method="post">
            <input type="hidden" name="form" value="">
            <div class="modal__sub">
                Name of the prod
            </div>
            <div class="modal__title" id="modal-title">
                Some title 
            </div>
            <div class="modal__content">
                <div class="form-group">
                    <label for="">Enter your name</label>
                    <input type="text" name="name">
                </div>
                <div class="form-group">
                    <label for="">Enter your phone</label>
                    <input type="tel" name="phone">
                </div>
                <div class="form-group">
                    <button type="submit" class="btn">
                        <span>Send</span>
                    </button>
                </div>
            </div>
        </form>
    </div>

This is my js script:

 $(document).on("submit", "form", function () {
        var e = $(this),
            t = !1;
        return (
            e.find("input").removeClass("error"),
            e.find("input").parent().removeClass("error"),
            e.find('[name="phone"]').each(function () {
                "" == $(this).val() && ($(this).addClass("error"), $(this).parent().addClass("error"), (t = !0));
            }),
            t ||
                $.ajax({ url: "send.php", type: "POST", dataType: "json", data: e.serialize() })
                    .done(function (e) {
                        $.fancybox.close("all"),
                            $.fancybox.open({ src: "#thanks" }),
                            setTimeout(function () {
                                $.fancybox.close("all");
                            }, 3e3),
                            $("input, textarea").val("");
                    })
                    .always(function () {
                        $("input[type=submit], button[type=submit]").removeAttr("disabled");
                    })
                    .fail(function (e) {
                        console.log(e);
                    }),
            !1
        );
    });

and this is my send.php file:

<?php 

require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = 'utf-8';

$form = $_POST['name'];
$phone = $_POST['phone'];
                     

$mail->isSMTP();                                
$mail->Host = 'mail.f-line.ge';                                                                                             
$mail->SMTPAuth = true; 
$mail->Username = 'no-reply@example.com'; 
$mail->Password = 'password'; 
$mail->SMTPSecure = 'ssl';                            
$mail->Port = 465; 
$mail->setFrom('no-reply@example.com');
$mail->addAddress('me@example.com');
$mail->isHTML(true);                                
$mail->Subject = 'FILLED FORM';
$mail->Body    = '' .$name . ' ' .$phone;
if(!$mail->send()) {
    echo 'Error';
} else {
    header('location: #thanks');
}
?>

0 Answers0