Log in

View Full Version : I want to send a html table in php mail .



farid007
08-03-2010, 11:46 PM
Hey guys,

i m trying to send an order confirmation email to the customer along with the items ordered.
here is the php code.
$to = "$email";

$from = "admin@peshawarirestaurant.co.cc";
$subject = "Your Booking Information";
//The Actual HTML Email Message to the customer

$message = "
<html>
<head>
<title></title>
</head>
<body>
<p>Hi $firstname,\n\nThank you for Booking at peshawarirestaurant.co.cc!\n\n
This email contains your Food order information.<br>
For Your Booking No:$bookingno!</p>
<table border=0 cellspacing=0 cellpadding=0 width= '500' align='center' >
<tr>
<th align=\"left\" >Item</th>
<th>Price</th>
<th > Quantitity </th>
<th align=\"right\"> Sub Total</th>
</tr>
<tr>
<td align=\"left\"> $name </td>
<td align=\"center\"> $price </td>
<td align=\"enter\">$quantity </td>
<td align=\"enter\">£ $sub_total </td>
</tr>
<td ></td >
<td ></td >
<td ><b><br>Total =</b></td>
<td align=\"center\"><b><br> £ $total </b></td>
</tr>
</table>
</body>
</html>
";

// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

$headers = "From: peshawarirestaurant.co.cc";


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

when the email is sent its just text with all the tages . No table is created.
Any body can help please.

regards

bluewalrus
08-04-2010, 04:58 AM
Does the mail client your testing it with support html email? That looks correct to me. You might want to try removing the table and send a simple html message first like <span style="color:#ff0000;">RED</span>, with the html, head, body tags.

fastsol1
08-04-2010, 01:17 PM
you are reasigning the the $headers variable rather than appending to it. Try changing this
$headers = "From: peshawarirestaurant.co.cc";
to

$headers .= "From: peshawarirestaurant.co.cc";

farid007
08-08-2010, 12:13 PM
Hi bluewalrus and fastsol1,

Thank you for ur kind replies.Have tried $headers .= "From: peshawarirestaurant.co.cc"; but didn't work .

Regards