【问题标题】:Not getting any email from PHP contact form [duplicate]没有收到来自 PHP 联系表的任何电子邮件 [重复]
【发布时间】:2019-03-18 18:01:16
【问题描述】:

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

【问题讨论】:

  • 停止使用@ 你正在抑制错误

标签: php forms email contacts


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-10
      相关资源
      最近更新 更多