Ajax表单需要很长时间才能发送电子邮件

时间:2016-02-16 14:51:50

标签: javascript php jquery ajax contact-form

我的网站上有一个Ajax联系表单,实际上目前正在运行,但是从表单编译的电子邮件大约需要50分钟到达我的收件箱,这里是代码,有谁知道可能导致这种情况过多时间差距?

Jquery的

$("#contactForm").submit(function(event){
        // cancels the form submission
        event.preventDefault();
        submitForm();
    });

    function submitForm(){
        // Initiate Variables With Form Content
        var name = $("#name").val();
        var email = $("#email").val();
        var message = $("#message").val();

        $.ajax({
            type: "POST",
            url: "form-process.php",
            data: "name=" + name + "&email=" + email + "&message=" + message,
            success : function(text){
                if (text == "success"){
                    formSuccess();
                }
            }
        });
    }
    function formSuccess(){
        $( "#msgSubmit" ).removeClass( "hidden" );
    }

HTML

<div id="form-container">
            <form role="form" id="contactForm">
                <input id="name" class="input" type="text" placeholder="Your name" name="name">
                <input id="email" class="input" type="text" placeholder="Contact email address" name="email">
                <textarea id="message" class="input message" placeholder="What would you like to discuss?" name="message"></textarea>
                <input id="form-submit" class="submit" type="submit" value="Send Message" name="submit">
            </form>
        </div>

PHP

<?php
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];

$EmailTo = "contact@etcetcetc.co.uk";
$Subject = "New Message Received";

// prepare email body text
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";

$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";

$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From:".$email);

// redirect to success page
if ($success){
   echo "success";
}else{
    echo "invalid";
}

?>

0 个答案:

没有答案