2016-10-19 62 views
1

我在我的網頁上有一個聯繫表,所以我通過電子郵件發送郵件,但它不起作用。html聯繫表格不起作用

我試圖通過使用GET模式和手動參數

<a href="contactpage.php?name=name&email=em&message=men">send</a> 

和它的作品PHP代碼來發送消息,所以也許錯誤HTML代碼。

HTML代碼:

<form id="contactForm" class="contact-form" name="formulario" method="post" action="contactpage.php"> 
    <div class="form-group form-icon-group"> 
     <input class="form-control" name="name" placeholder="Nombre" type="text" required/> 
     <i class="fa fa-user"></i> 
    </div> 
    <div class="form-group form-icon-group"> 
     <input class="form-control" name="mail" placeholder="Email" type="text" required/> 
     <i class="fa fa-envelope"></i> 
    </div> 
    <div class="form-group form-icon-group"> 
     <textarea class="form-control" name="mes" placeholder="Mensaje" rows="10" required></textarea> 
     <i class="fa fa-pencil"></i> 
    </div> 
    <div class="text-center"> 
    <input type="submit" name="submit" value="Envía tu solicitud" class="btn btn-primary"> 
    </div> 
</form> 

和PHP代碼:

<?php 
$nombre = $_POST['name']; 
$email = $_POST['mail']; 
$mensaje = $_POST['mes']; 

$header = 'From:'. $email."\r\n"; 
$header.="X-Mailer: PHP/". phpversion(). "\r\n"; 
$header .= "Mime-Version: 1.0 \r\n"; 
$header .= "Content-Type: text/plain"; 

$mensaje = "Este mensaje fue enviado por " . $nombre . ", con email " . $email . " \r\n"; 
$mensaje .= "Su e-mail es: " . $email . " \r\n"; 
$mensaje .= "Mensaje: " . $_POST['mes'] . " \r\n"; 
$mensaje .= "Enviado el " . date('d/m/Y', time()); 

$para = '[email protected]'; 
$asunto = 'Contacto desde la web'; 

$bool = mail($para, $asunto, utf8_decode($mensaje), $header); 

if($bool){ 
    echo "Mensaje enviado"; 
}else{ 
    echo "Mensaje no enviado"; 
} 
?> 

謝謝大家!

回答

0
$to  = '[email protected]'; 
$subject = 'the subject'; 
$message = 'hello'; 
$headers = 'From: [email protected]' . "\r\n" . 
    'Reply-To: [email protected]' . "\r\n" . 
    'X-Mailer: PHP/' . phpversion(); 

mail($to, $subject, $message, $headers); 

http://www.php.net/manual/en/function.mail.php

+0

謝謝你,但正如我所說,如果我用GET方式我的郵件功能的工作原理,所以問題不在郵件功能的參數。 – johndig

+0

這將與post方法一起工作,你也可以通過phpmailer發送郵件 –