未收到来自 PHP 联系表的任何电子邮件

Not getting any email from PHP contact form

因此,我正在创建一个简单的网站,并在 "contact us" 页面上放置了一个联系表,用于将消息邮寄到那里。该表格实际上给出了一条成功消息,表明电子邮件已发送,但我没有收到。我也检查了 spam/junk 文件夹。我在 apache 本地服务器上测试了这个。 (我的电子邮件是正确的。出于隐私问题,我已经在此处的代码中这样声明了。) 由于我对编码还很陌生,所以我可以了解一下我所缺少的东西吗?

 <?php
header('Content-type: application/json');
$status = array(
    'type'=>'success',
    'message'=>'Mesazhi u dergua!'
);
$name = @trim(stripslashes($_POST['emri'])); 
$email = @trim(stripslashes($_POST['email'])); 
$phoneno = @trim(stripslashes($_POST['telefon']));
$message = @trim(stripslashes($_POST['mesazhi'])); 
$email_from = $email;
  $email_to = 'name.surname@mail.net';
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Phone NO: ' . $phoneno . "\n\n" . 'Message: ' . $message;
$success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die; 

?>

<div class="contact-form">
            <form action="sendemail.php" name="contact-form" method="post">
                <input type="text" name="emri" placeholder="Emri" />
                <input type="email" name="email" placeholder="Email" />
                <input type="tel" name="telefon" placeholder="Nr Telefoni"/>
                <textarea name="text" id="text" rows="8" placeholder="Teksti" name="mesazhi"></textarea>
                <input type="submit" class="btn-send" value="Dergo">
            </form>
        </div>

使用这个代码 mail($email_to, $subject, $body, 'From: <'.$email_from.'>');

您在每个函数调用中都使用了 @。删除它们,您可能会看到问题所在。