没有从PHP联系表中收到任何电子邮件

时间:2018-10-13 21:39:36

标签: php forms email contacts

因此,我正在创建一个简单的网站,并在“与我们联系”页面上放置了一个联系表单,该表单应将邮件邮寄到那里。该表格实际上给出了一条成功消息,表明已发送电子邮件,但我什么也没收到。我也检查了垃圾邮件/垃圾文件夹。我在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>

2 个答案:

答案 0 :(得分:-1)

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

答案 1 :(得分:-1)

您在每个函数调用上使用@。删除它们,您可能会发现问题出在哪里。