我的 php 文件后出现问题。
我已经测试了这个(下)并且它工作正常
<?php
$fto = 'myemail@gmail.com';
$fsubject = 'Test';
$fmessage = 'Message';
$fheaders = 'From: test@test.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($fto, $fsubject, $fmessage, $fheaders);
?>
但我正在尝试使用 ajax 为我发送它,但由于某种原因它不起作用:c
我试过这个:
(PHP)
<?php
$fto = 'myemail@gmail.com';
$fsubject = $_POST['subj'];
$fmessage = $_POST['all'];
$fheaders = 'From: ' . $_POST['email'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($fto, $fsubject, $fmessage, $fheaders);
?>
(jQuery)
$("#form").submit(function(e){
e.preventDefault();
var name = $("#name").val();
var email = $("#email").val();
var text = $("#message").val();
var subj = "Novo Parceiro - " + name;
var all = "Nome : " + name + "\nE-mail : " + email + "\nMensagem : " + text;
var dataString = name + email + text + all + subj;
if (name.length > 3){
$.ajax({
type: "POST",
url: "/scripts/mailform.php",
data: dataString,
success: function(){
$('#form').trigger("reset");
}
});
} else{
$('#errorform').slideDown(200);
}
return false;
});