2014-10-20 27 views
0

我在我的網站上寫了代碼聯繫我們的頁面,但它不工作。我檢查了一切,但仍然沒有收到電子郵件,當我嘗試我的自我。
聯繫我們頁面腳本不起作用

我有這個形式:

<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

回答

0

這會幫助你瞭解你的需要格式化電子郵件。您在電子郵件中缺少重要的標題信息。我會猜測你的電子郵件是否會進入垃圾郵件,因爲你使用的方法可能會將它推送到垃圾郵件而沒有正確的標題。或者希望這種格式可以幫助你弄清楚。如果沒有錯誤,我們不能爲您做很多事情,並且我們不知道您的盒子的配置。也許它不支持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

相關問題