2016-04-10 77 views
-2

我的聯繫表格不起作用。郵件不會發送到給定的電子郵件地址。 表格成功但電子郵件未送達。另一個問題有另一個代碼使用if標籤,這不適用於我的腳本。PHP聯繫表不提供郵件

我使用的HTML代碼是:

<form class="form" id="form1" action="mail.php" method="post"> 

    <p class="name"> 
    <input name="name" type="text" class="validate[required,custom[onlyLetter],length[0,100]] feedback-input" placeholder="NAME" id="name" /> 
    </p> 

    <p class="email"> 
    <input name="email" type="text" class="validate[required,custom[email]] feedback-input" id="email" placeholder="E-MAIL" /> 
    </p> 

    <p class="text"> 
    <textarea name="text" class="validate[required,length[6,300]] feedback-input" id="comment" placeholder="WHAT'S UP?"></textarea> 
    </p> 


    <div class="submit"> 
    <input type="submit" name="submit" value="SEND" id="button-blue"/> 
    <div class="ease"></div> 
    </div> 
</form> 

PHP腳本我用的是:

<?php 

// We create a variable for name value 
$name = $_POST['name']; 

// We create a variable for email value 
$email = $_POST['email']; 

// We create a variable for message value 
$message = $_POST['text']; 

// We provide an e-mail address from which the email is sent 
$from = "[email protected]"; 

// Provide the e-mail address on which you want to receive messages 
$to = "[email protected]"; 

// Provide the subject of the e-mail 
$subject = "Contact form from xyz.com"; 

// We prepare the message body 
$emailbody = ""; 
$emailbody .= "Message: " . $message . "\n"; 

// We add UTF-8 to the header of our message 
$header = ""; 
$header .= "From:" . $from . " \n"; 
$header .= "Content-Type:text/plain;charset=utf-8"; 


// Sending message 
$success = mail($subject, $emailbody, $header); 

// Redirect after sending the message 
if ($success){ 
print "<meta http-equiv=\"refresh\" content=\"0;URL=de/confirmation_signup.html\">"; 
} 
else{ 
print "<meta http-equiv=\"refresh\" content=\"0;URL=de/error.html\">"; 
} 
?> 

任何人有一個線索是什麼形式裏面去錯了嗎?

回答

0

你正在通過增值郵件功能錯誤; 更改此:

mail($subject, $emailbody, $header); 

要這樣:

mail($to,$subject, $emailbody, $header); 

參見:http://php.net/manual/en/function.mail.php

+0

我fullfilled郵件功能巫婆$到,但它並沒有爲我工作,沒有電子郵件進來我找不到問題。 :( –