2014-01-24 172 views
-4

讓這個HTML聯繫表格發送電子郵件最簡單的方法是什麼?聯繫表格HTML到PHP

<div class="col-lg-4"> 
    <h4>Hire Me</h4> 
    <form role="form"> 
     <div class="form-group"> 
      <input type="name" class="form-control" placeholder="Your Name"> 
     </div> 
     <div class="form-group"> 
      <input type="email" class="form-control" placeholder="Your Email"> 
     </div>     
     <textarea class="form-control" rows="3" placeholder="Tell me about your project..."></textarea> 
     <br> 
     <button type="submit" class="btn btn-success">SUBMIT</button> 
    </form>    
</div><!-- /col-lg-4 --> 

回答

0

這個添加到窗體行

然後創建一個名爲電子郵件sending.php

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$message = $_POST['message']; 
$formcontent=" From: $name \n Email: $email \n Order Number: $order_number \n Sign Up for Newsletter: $newsletter \n Message: $message"; 
$recipient = "your email"; 
$subject = "Subject from $name"; 
$mailheader = "From: $email \r\n"; 
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
echo "Thank You! We will get back to you as soon as possible!" . " -" . "<a href='./index.php'> Back to site</a>"; 
?> 
0

您可以使用PHP代碼上面的答案,或者您可以使用其他那裏已經進行了「戰鬥測試」的項目,並且使用起來更安全。

快速谷歌搜索從github上給了PHPMailer:https://github.com/PHPMailer/PHPMailer