PHP邮件发送ajax [重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/24644436/php-mail-function-doesnt-complete-sending-of-e-mail" dir="ltr">PHP mail function doesn't complete sending of e-mail</a>
                            <span class="question-originals-answer-count">
                                (26 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2017-02-20 19:11:24Z" class="relativetime">3 years ago</span>.</div>
        </div>
    </aside>

I have a problem this PHP send mail.

I have this form in index.php page:

<form action="">
<input placeholder="Name" class="form" id="name" type="text" required/>
<input placeholder="Email" class="form" id="mail" type="email" required />
<input placeholder="Object" class="form" id="object" type="text" required />
<textarea placeholder="Type here..." id="text" class="form"></textarea>
<input class="formBtn" type="submit" id="submit"/>
<input class="formBtn" type="reset" />

This script on bottom of the index.php

<script>
$('#submit').click(function() {
    var nameform = $('#name').val();
    var mailform = $('#mail').val();
    var objectform = $('#object').val();
    var textform = $('#text').val();
    var mailcomplete = 'Name='+nameform+'Mail='+mailform+'Object='+objectform+'Message='+textform;

    $.ajax({
        type: "POST",
        url: 'php/mail.php',
        data: mailcomplete,
        success: function() {
            alert("Mail send OK!");
        }

    });
});

and this in php/mail.php

 <?php

$name = $_POST["nameform"];
$mail = $_POST["mailform"];

mail($mail, $name, "Hello!");

?>

But don't work... Can you help me? Tnk

</div>

Change your php/mail.php to this:

<?php

$name = $_POST["Name"];
$mail = $_POST["Mail"];

mail($mail, $name, "Hello!");

?>

Also in your script in the index.php file, change:

var mailcomplete = 'Name='+nameform+'Mail='+mailform+'Object='+objectform+'Message='+textform;

to

var mailcomplete = 'Name='+nameform+'&Mail='+mailform+'&Object='+objectform+'&Message='+textform;

That should work. The problem was that you are passing the variables Name and Mail in data and not nameform and mailform. Also, the data formatting was incorrectly done in the script. Lemme know if it still doesn't work.

chane your button to

<input class="formBtn" type="button" id="submit"/>

and

var mailcomplete = 'Name='+nameform+'&Mail='+mailform+'&Object='+objectform+'&Message='+textform;

and also the php script

<?php
$name = $_POST["Name"];
$mail = $_POST["Mail"];
mail($mail, $name, "Hello!");