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

问题描述:

我在我的网站上写了代码联系我们的页面,但它不工作。我检查了一切,但仍然没有收到电子邮件,当我尝试我的自我。
联系我们页面脚本不起作用

我有这个形式:

<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  = "[email protected]"; // 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. 
    } 
    ?> 
+2

它目前做些什么?是否引发错误?你有一个邮件服务器设置? – MLeFevre 2014-10-20 10:41:20

+0

'error_reporting(E_ALL); ini_set('display_errors',1);' – 2014-10-20 10:42:47

+0

没有error.it显示消息“Mail Sent。Thank you,'发送人姓名',我们会尽快与您联系。 ,但是当我检查我的收件箱时,没有收到电子邮件。 – 2014-10-20 10:43:40

这会帮助你了解你的需要格式化电子邮件。您在电子邮件中缺少重要的标题信息。我会猜测你的电子邮件是否会进入垃圾邮件,因为你使用的方法可能会将它推送到垃圾邮件而没有正确的标题。或者希望这种格式可以帮助你弄清楚。如果没有错误,我们不能为您做很多事情,并且我们不知道您的盒子的配置。也许它不支持PHP邮件功能?

<?php 
$to = "[email protected], [email protected]"; 
$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: <[email protected]>' . "\r\n"; 
$headers .= 'Cc: [email protected]' . "\r\n"; 

mail($to,$subject,$message,$headers); 
?> 
+0

那么这个没有任何解释的“入门”代码会做得更好吗? – 2014-10-20 10:51:21

+0

这应该有助于他理解他需要如何格式化电子邮件。他在电子邮件中缺少重要的标题信息。我会猜测他的电子邮件是否会进入垃圾邮件,因为他使用的方法可能会将其推送到垃圾邮件,而没有正确的标题或提供给他的格式可能会帮助他找出答案。 – Binary101010 2014-10-20 10:57:41

+0

你应该在你的回答中写下来。 – 2014-10-20 10:58:47