以下是我的php代码。当我点击“发送电子邮件”按钮它工作正常。但它似乎不是我的收件箱。它被路由到垃圾邮件文件夹:
<?php
function sendmail(){
$message = $_POST['message'];
$email = $_POST['email'];
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$to = 'mpylla@gmail.com';
$subject = 'From :'.$email;
$message1 = 'From: '.$name."\nEmail: ".$email."\nMessage: ".$message;
mail($to, $subject, $message1);
}
sendmail();
?>
这个ajax脚本在我的HTML代码中:
$("#submit").click(function(e) {
var name = $("#name").val();
var lastname = $("#lastname").val();
var email = $("#email").val();
var message = $("#message").text();
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if (!emailReg.test(email)) {
alert('Ju lutem shkruan nje e-mail valide');
return false;
}
if (email.length == 0) {
alert("Email duhet te shenohet");
return false;
}
if (name.length == 0) {
alert("Emri duhet te shenohet");
return false;
}
if (lastname.length == 0) {
alert("Mbiemri duhet te shenohet");
return false;
}
if (message.length == 5) {
alert("Mesazhi duhet te shenohet");
return false;
} else {
$.ajax({
type: "POST",
url: "mail.php",
data: $("#myform").serialize(),
success: function(response) {
$("#sukses").fadeIn('slow');
setTimeout(function() {
$("#sukses").fadeOut('slow');
document.getElementById('myform').reset();
}, 100);
clearInterval();
}
});
}
e.preventDefault();
e.stopPropagation();
});