这是我的表格。但它没有发送邮件,也没有显示任何错误。发送邮件功能在服务器上工作正常。我如何使其功能,我发现他们的详细信息被插入到表单中,但电子邮件不发送。
<?php
ob_start();
session_start();
$txtname = $_POST['txtname'];
$txtemail = $_POST['txtemail'];
$txtnumber = $_POST['txtnumber'];
$cbocountry = $_POST['cbocountry'];
$rooms = $_POST['rooms'];
$Arrivaldate = $_POST['Arrivaldate'];
$departure = $_POST['departure'];
$Houseboat = $_POST['Houseboat'];
$adults = $_POST['adults'];
$children = $_POST['children'];
$Bookingdetails = $_POST['Bookingdetails'];
$body="<b><u>ANGEL HOUSEBOATS</u></b><br><br>
<table border=\"0px\" bgcolor=\"#FFFFFF\">
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Name </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $txtname</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> E-mail </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $txtemail</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Telephone </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $txtnumber</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Country </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $cbocountry</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> No.of Rooms </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $rooms</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Arrival </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $Arrivaldate</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Departure </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $departure</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Houseboat </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> $Houseboat</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\" width=\"150px\"> Number of People </td><td bgcolor=\"#dcdcdc\"> <font face=\"Arial\" size=\"2px\"><b> No.of Adults : $adults | No.of Childern : $children</b></font></td>
</tr>
<tr>
<td bgcolor=\"#dcdcdc\"> Comments </td> <td bgcolor=\"#dcdcdc\"><font face=\"Arial\" size=\"2px\"><b> $Bookingdetails </b></font></td></tr>";
$headers = "Content-Type: text/html; charset=iso-8859-1"."\r\n"."From: $txtemail" . "\r\n" .
"Reply-To: $txtemail" . "\r\n"
;
$to="myemail@gmail.com";
$subject="$txtemail";
$message="<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2px\"><b>A message has been sent by $txtname ($txtemail). The message is given below:</b></font><br><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"3 px\">";
$message.=$body."</font><br><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2 px\"><b>"."This is a computer generated mail</b></font><br><br><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1px\">www.mydomain.com</font>";
$mailsent=mail($to, $subject, $message, $headers);
print_r($mailsent);
if($mailsent)
{
$headers = "Content-Type: text/html; charset=iso-8859-1"."\r\n"."From: Bookings <www.mydomain.com>" . "\r\n" .
"Reply-To: info@mydomain.com" . "\r\n"
;
$to=$_POST['txtemail'];
$subject=" HOUSEBOATS!";
$message="Thanks for choosing <b> HOUSEBOATS</b>.";
$mailsent=mail($to, $subject, $message, $headers);
{
//Clear the Body
$body = "Message from www.yourdomain.com<br/><br/>
Thanks for your Message! We will contact you soon.";
{
header("Location:success.html");//Change the address
}
}
}
?>
答案 0 :(得分:0)
尝试将邮件部分更改为此。将您的$body
更改为$message
并分成更小的部分以便于控制。
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/html; charset=UTF-8";
$headers[] = "From: Bookings www.mydomain.com <myemail@gmail.com>";
$headers[] = "Reply-To: Bookings <myemail@gmail.com>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
$message = "Hello " . $txtname. ",\r\n\n";
$message .= "<table border='0px' bgcolor='#FFFFFF'>";
$message .= "<tr>";
$message .= "<td bgcolor='#dcdcdc' width='150px'>";
$message .= " Name </td>";
$message .= "<td bgcolor='#dcdcdc'> <font face='Arial' size='2px'>";
$message .= "<b> ". $txtname ."</b></font></td>";
$message .= "</tr>";
$message .= "Best regards,\r\n\r\nJohn Doe (bookings\r\n\r\n";
mail($txtemail, '=?utf-8?B?'.base64_encode($subject).'?=', $message, implode("\r\n", $headers));