无法接收来自PHP mail()的电子邮件


Cannot receive email from PHP mail()

我正在尝试制作一个联系人表格,用户可以在其中填写详细信息,并将其发送到我的电子邮件地址。PHP脚本说它已经发送,但当我检查电子邮件时,没有邮件。我也在尝试使用AJAX来实现这一点。这是我的代码

                        $('#submit').click(function () {
                                    var name = $('#name').val();
                                    var email = $('#email').val();
                                    var message = $('#message').val();
                                    $.ajax({
                                        type: 'POST',
                                        url: 'send.php?name=' + name,
                                        data: 'name=' + name + '&email=' + email + '&message=' + message,
                                        success: function (result) {
                                         //   $('#submit_wrp').load(location.href + ' #submit');
                                                $("#result").html(result);
                                           // $('#submit').val("Invited");
                                           // alert(name + " "  + email);
                                        },
                                        error: function (result) {
                                            alert("error" + name);
                                                $("#result").html(result);
                                        }
                                    });
                                });

这是PHP代码

$Rname = $_POST['name'];
$meesg = $_POST['message'];
$email = $_POST['email'];
$to = "example@gmail.com";
$subject = "Review";
$message = $meesg;
$headers = "From:" + $Rname + $email;
mail($to, $subject, $message, $headers);
  if (mail($to, $subject, $message, $headers)) {
    echo "Mail was sent and has done its job.";
} else {
    echo "Error, check your logs.";
}

请帮忙!!!!

对值进行硬编码,然后再次检查。

$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "'r'n" .
'Reply-To: webmaster@example.com' . "'r'n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);

如果出现问题,请检查服务器上的smtp设置。

您在托管公司的论坛上搜索过邮件php的可能性吗?尝试查看sendmail_path:

<?php
   phpinfo();  
?>

可能是配置不正确。

此外,你可能需要更多的邮件头来发送你的电子邮件,以防止过滤到垃圾邮件箱。

$headers = "MIME-Version: 1.0" . "'r'n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "'r'n";
$headers .= "From: frommail@gmail.com" . "'r'n" ."Reply-To: tomail@gmail.com". "'r'n" ."X-Mailer: PHP/" . phpversion();