PHP Mail不起作用,在脚本页面停止

时间:2019-07-07 18:59:09

标签: php html contact-form

每当我单击发送消息时,它就会在contact.php脚本上停止。并显示黑白页面。如果您也想检查html编码,我可以在这里发送。在代码上有没有人为错误,所以我禁用了它。我读到我需要在脚本中添加标头,所以我也添加了它,我在errlog上看到$ errName未定义变量的错误:所以我删除了所有验证,现在我收到此错误出了点问题,请重试!我在脚本中添加的。新的编码已更新...

     <?php
  if (isset($_POST["submit"])) {
  $name = $_POST['name'];                 // Sender's name
  $email = $_POST['email'];     // Sender's email address
  $message = $_POST['message'];    // Sender's message
  $from = 'Demo Contact Form';    
  $to = 'aakkirocx@gmail.com';     // Recipient's email address
  $subject = 'Message from Contact Demo ';
  $header = "From: noreply@example.com\r\n"; 
  $header.= "MIME-Version: 1.0\r\n"; 
  $header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
  $header.= "X-Priority: 1\r\n";
  $body ="From: $name\n E-Mail: $email\n Message:\n $message";


  $status =  (mail ($to, $subject, $body, $from, $header)); 

  if($status)
{ 
    echo '<p>Your mail has been sent!</p>';
} else { 
    echo '<p>Something went wrong, Please try again!</p>'; 
}
 }

?>

0 个答案:

没有答案