“联系我们”页面脚本不起作用


Contact Us page script is not working

我已经在我的网站联系我们页面上写了代码,但它不起作用。我检查了所有的东西,但当我自己尝试时,仍然没有收到电子邮件

我有这样的表格:

<form id="contact-form"  class="cform" method="post">
          <label class="hide" 
                 for="author">
          Full Name
          </label>
          <input class="input-fields" id="full_name" name="full_name" type="text" required="required" placeholder="Full Name" value=""/>
          <label class="hide" for="email">Email</label>
          <input class="input-fields req-email" id="email" name="email" type="text" required="required" placeholder="Email Address" value=""/>
          <label class="hide" for="subject_title">Subject title</label>
          <input class="input-fields" id="subject_title" name="subject_title" type="text" required="required" placeholder="Subject Title" value=""/>
          <label class="hide" for="comment">Message</label>
          <textarea id="comment" class="input-fields form-control" required placeholder="Message" name="comment" cols="40" rows="200"></textarea>
          <input name="submit" type="submit" id="submit-contact-info" class="contact-info-submit form-submit-button span2" value="Send message">
        </form>

这是php:

<?php 
 if(isset($_POST['submit'])){
     $to        = "mail@asrhouse.com"; // this is your Email address
     $from      = $_POST['email']; // this is the sender's Email address
     $full_name = $_POST['full_name'];
     $subject   = $_POST['subject_title'];
     $subject2  = "Copy of your form submission";
     $message   = $full_name . " wrote the following:" . "'n'n" . $_POST['comment'];
     $message2  = "Here is a copy of your message " . $full_name . "'n'n" . $_POST['comment'];
 $headers   = "From:" . $from;
 $headers2  = "From:" . $to;
 mail($to,$subject,$message,$headers);
 mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
 $msgss= "Mail Sent. Thank you " . $full_name . ", we will contact you shortly.";
 // You can also use header('Location: thank_you.php'); to redirect to another page.
   }
    ?>

这将帮助您了解如何格式化电子邮件。您的电子邮件中缺少重要的标题信息。我猜你的电子邮件要么会进入SPAM,因为你使用的方法可能会在没有适当标题的情况下将其推送到SPAM。或者希望这种格式能帮你弄清楚。如果没有错误,并且我们不知道您盒子的配置,我们将无法为您做太多工作。也许它不支持PHP邮件功能?

<?php
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "'r'n";
$headers .= "Content-type:text/html;charset=UTF-8" . "'r'n";
// More headers
$headers .= 'From: <webmaster@example.com>' . "'r'n";
$headers .= 'Cc: myboss@example.com' . "'r'n";
mail($to,$subject,$message,$headers);
?>