邮件表格不会与AJAX一起发送

时间:2017-02-17 15:35:41

标签: javascript php jquery ajax email

我在互联网上尝试了大约一百万件事来使这个工作,但我只是难倒。我无法弄清楚它为什么不再发邮件了。

它会像想要的那样发出提醒,但邮件不会发送到我的电子邮箱。

这是我的代码:



<script>
        $(document).ready(function(){
        $("#contact-form").on("submit", function(e){
                e.preventDefault();
            dataString = jQuery('form#contact-form').serialize();
            jQuery.ajax({
                type: "POST",
                url: "mail.php",
                data: dataString,
                success:  function(data)
                { 
                    alert('Form successfully submitted.');
                },
                error:  function(data)
                { 
                    
                }
            }); 
        });
        });
       
       
       
    </script>
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<form id="contact-form" name="contactform" method="POST">

<input contenteditable="true" style="width:68%;" maxlength="32" placeholder="" class="contact_input" name="name" id="naam" required/></h2>

<input contenteditable="true" style="width:100%;" maxlength="512" placeholder="" class="contact_input" name="message" id="onderwerp" required/></h2>

<input contenteditable="true" maxlength="50" style="width:47.5%;" placeholder="" class="contact_input" name="email" id="contact1" required/> en

<input contenteditable="true" maxlength="50" style="width:92.7%;" placeholder="" class="contact_input" name="contact2" id="contact2"/></h2>

<h3><input type="submit" id="submit-button" value="groetjes" class="btn btn-primary"></h3>
 
 </form>
&#13;
&#13;
&#13;

Mail.php

<?php
$name = $_POST['name'];
$contact1 = $_POST['email'];
$contact2 = $_POST['contact2'];
$inhoud = $_POST['message'];


$to = "";
$subject = "Contactform";
$from = "";

$message = "";
$headers = "From:" . $from;

mail($to, $subject, $message, $headers);

0 个答案:

没有答案