DiigIT | IT Community
No Profile Image
Welcome Guest
New User? Register | Login

PHP Mail function with data

By: rekha singh | 16 Feb 2010 6:57 pm

Hi,

I need some help on making my mail function for my project, i need to add the items in the mail but I always got an error somebody help me on how to do this it would be a great help.

Below are the codes:

$message = "
http://www.w3. org/1999/ xhtml\">
<head>
<title></title>
</head>

<body>
<table border=\"1\" cellpadding= \"0\" cellspacing= \"0\">
<tr>
<td height=\"6\" colspan=\"6\ "><hr /></td>
</tr>
<tr>
<td height=\"164\ " colspan=\"6\ " align=\"left\ " valign=\"top\ " style=\"font- family:Verdana, Arial, Helvetica, sans-serif; font-size:11px\ "><br />
<h5>
ORDER INFORMATION< br />
============ ===<br />
<br />
<b>*Note: Please email us after you made the payment.</b>
</h5>
<p>
Order Date: $petsa
</p>
<table border=\"0\" align=\"center\ " width=\"960\ " style=\"font- family:Verdana, Arial, Helvetica, sans-serif; font-size:11px\ " cellpadding= \"0\" cellspacing= \"0\">
<tr height=\"30\ " style=\"font- weight: bold;\">
<td>Item</td>
<td>Description< /td>
<td>Price</td>
<td>Quantity< /td>
<td>Total</td>
</tr>".
while($cart = mysql_fetch_ array($cart_ result))
{
$total = $cart['price' ] * $cart['quantity' ];

$subtotal +=$total;

"<tr height=\"20\ ">
<td>$cart[product_ code]</td>
<td>$cart[product_ name] $cart[color] $cart[size]< /td>
<td>PHP $cart[price] </td>
<td width='130'> $cart[quantity] </td>
<td>PHP $total</td>
</tr>";
}
."<tr>
<td align=\"right\ " height=\"25\ "></td>
<td align=\"right\ "></td>
<td align=\"right\ "></td>
<td align=\"right\ " valign=\"bottom\ "><b>Order Sub-Total: &nbsp;</b></ td>
<td align=\"left\ " valign=\"bottom\ "><b>PHP $subtotal</b> </td>
<td align=\"right\ " colspan=\"2\ "></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>";

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/html; charset=iso- 8859-1" . "\r\n";
$headers .= 'From: donotreply@somebody .com' . "\r\n";

mail("$to", "Checkout", $message, $headers);

 

Comments

$to = "$_POST[email] ";
$subject = "Forgotten Possword";
$message = "Hello! This is your Password of hummaya.com" ;
$from = "hummaya.com" ;
$headers = "From: $from";
mail($to,$subject, $message, $headers) ;

 

By: rekha singh | 16 Feb 2010

Hi,

I just would like the script below to be added in the message part. when I try to do this script it only has one result and the rest of the data is not working. for example the result is only: you order 1 banana 200 and the other product does not print like the 1 orange 120, 2 mango 350 and etc. please help..

while($cart = mysql_fetch_ array($cart_ result))

{

$total = $cart['price' ] * $cart['quantity' ];

$subtotal +=$total;

"<tr height=\"20\ ">

<td>$cart[product_ code]</td>

<td>$cart[product_ name] $cart[color] $cart[size]< /td>

<td>PHP $cart[price] </td>

<td width='130'> $cart[quantity] </td>

<td>PHP $total</td>

</tr>";

 

By: rekha singh | 16 Feb 2010

If we need to send some data comes from database in table format via email to other email automatically to using PHP script like newsletter.

Code:-
<?php
$senderheaders  = "From: dept@xyz.com\r\n";
$senderheaders .= "Content-type: text/html\r\n";
$subject="Dept Category Item Detail";
$sendId='test@xyz.com';
$textTosend='


  <table width="700px" align="center">
  <tr>
  <td colspan="3" align="center"  class="title" height="30px"><strong>Category Item Detail </strong></td>
  </tr>


  <tr>
  <td >
  <strong>Item Name</strong>  </td>
  <td >
  <strong>Item Qty.</strong>  </td>


  </tr>';


$selItem="select * from item where cate_id=$Id";
  $itemRs=mysql_query($selItem,$dbc);
  while($itemRow=mysql_fetch_array($itemRs)){
  $itemDetail=itemDetail($itemRow["product_id"],$dbc);


  $textTosend.='<tr>
  <td >
  '.$itemDetail["item_name"].'  </td>
  <td >
  '.$itemDetail["price_unit"].'  </td>
  <td >
  '.$itemRow["quantity"].'  </td>
  </tr>
  ';
}

$textTosend.='</table><br>
;

if(mail($sendId,$subject,$textTosend,$senderheaders)){
  echo '<div class="success">Echo Mail Send  SuccessFully</div>';
  }
  ?>
 

By: rekha singh | 17 Feb 2010

Leave a comment

Enter the text in the image
img
Can't read?
Type the characters you see in the picture below.


Close Move