我目前正在嘗試創建一個非常基本的PHP腳本,它從html表單獲取內容,將它們存儲爲變量,然後發送包含所述信息的電子郵件。通過PHP解析HTML表單併發送電子郵件
執行此操作後,似乎所有工作都離開實際的消息信息。
我的HTML寫着:
<table style="width:100%">
<form action="form_complete.php" method="POST">
<tr>
<th> <input type="text" name="name" required placeholder="Name" /> </th>
<th> <input type="text" name="email" required placeholder="Email" /> </th>
</tr>
<tr>
<th> <input type="text" name="mobile" required placeholder="Mobile" /> </th>
<th> <input type="text" name="subject" required placeholder="Email Subject" /> </th>
</tr>
<tr>
<th colspan="2"> <textarea name="message" required placeholder="Enter your message"></textarea> </th>
<tr>
<th> </th>
<th> <input id="submit" type="submit" name="submit" value="Send" /> </th>
</tr>
和有關PHP讀取:
if(isset($_POST['submit'])){
$to = "[email protected]"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$mobile = $_POST['mobile'];
$subject = $_POST['subject'];
$getMessage = $_POST['message'];
$subject2 = "Receipt of email submission";
$message = "You have received a new email from " . $name . ". \n Message: " . $getMessage;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2);
就像我說的,當我檢查電子郵件的內容,名稱解析精,就像手機號碼和主題一樣,但是信息的內容似乎並沒有,我不知道爲什麼。
的可能的複製[如何使用PHP來發送電子郵件?(http://stackoverflow.com/questions/5335273/how-to-發送電子郵件使用PHP) – cb0
你是什麼意思,但消息的內容似乎並沒有?它如何格式不正確? –