Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
Please help how to send html mail to client and to myself with different headers and message using if (mail())}{
(if a mail is sent to client and me ,different headers and messages will go to client and to me as well. If a mail is sent to me, it will show a product code and not to a client mail)
Is there something wrong in:
if (mail ($email,'Order',$message,$headers)){}
statement?
The code I have problem with is this:Code: Select all
# -=-=-=- MIME BOUNDARY
$mime_boundary .= "----Sales Department----";
# -=-=-=- MAIL HEADERS
$eol="\r\n";
$Bcc = 'test@test.com';
if (mail ($email,'Order',$message,$headers)){
# -=-=-=- MAIL HEADERS to Client
$headers .= "Content-Type: text/html; charset=ISO-8859-1 ".$eol;
$headers .= "MIME-Version: 1.0 ".$eol;
$headers .= 'From: Sales Department<'.$Bcc.'>'.$eol;
$headers .= 'Reply-To: Sales Department<'.$Bcc.'>'.$eol;
$headers .= 'Return-Path: Sales Department<'.$Bcc.'>'.$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v" .phpversion().$eol;
# -=-=-=- HTML EMAIL PART
$message .= "<html>\n";
$message .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"default.css\" media=\"screen\">";
$message .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"print.css\">";
$message .= "$mime_boundary<br>\n\n";
$message .= "ORDER NUMBER: $orderid<br>\n\n";
$message .= "ORDER DATE: $orderdate<br>\n\n";
$message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:14px; color:#666666;\"><br>\n";
$message .= "Dear $ttle\n $fname\n $lname:<br>\n";
$message .= "This email is to confirm that \"We\" have received your order.<br>\n";
$message .= "<font face=\"MS Sans Serif\" size=2 color=#F2007A>Your delivery details:</font><br>\n\n";
$message .= "Address:$addr1, $addr2, <br>\n\n";
$message .= "City: $city<br>\n\n";
$message .= "County: $county<br>\n\n";
$message .= "Country: $country<br>\n\n";
$message .= "Postal Code: $pcode <br>\n\n";
$message .= "Telephone: $phone<br>\n\n";
$message .= "Fax: fax<br>\n\n";
$message .= "Email: $email<br>\n\n";
$message .= "<font face=\"MS Sans Serif\" size=2 color=#F2007A>Your payment details:</font><br>\n\n";
$message .= "Name on Card: $card_name<br>\n\n";
$message .= "Card Type: $cardType<br>\n\n";
$message .= "Card Number: $cardNumber<br>\n\n";
$message .= "Card Code: $card_code<br>\n\n";
$message .= "Card Expiry: $cardMonth, $cardYear<br>\n\n";
$message .= "<br>\n";
$message .= "<font face=\"MS Sans Serif\" size=2 color=#F2007A>Your ordered items:</font><br>\n\n";
$message .= "<table border=1 cellpadding=0 cellspacing=0 width = 50% bordercolor=#eeeeee align=left>";
$message .= "<tr bordercolor=#CCCCFF bgcolor=#eeeeee align=center>";
$message .= "<th width=100%><h4><div align=center>Product Description</div></h4></th>";
$message .= "<th width=100%><h4><div align=center>Unit Price</div></h4></th>";
$message .= "<th width=100%><h4><div align=center>Quantity</div></h4></th>";
$message .= "<th width=100%><h4><div align=center>Total Unit Price</div></h4></th>";
$message .= "</tr>";
foreach ($cart as $code => $qty) {
$product = get_product_details($code);
$message .= "<tr>";
$message .= "<td>";
$message .= "<a href = \"www.test.com/price_details.php?code=".$code."\"><font face=\"MS Sans
Serif\" size=2>".$product["name"];
if($product["colour"]!="") {
$message .= " (".$product["colour"].")"; }
if($product["watt"]!="") {
$message .= " (".$product["watt"].")"; }
if($product["lamptype"]!="") {
$message .= " (".$product["lamptype"].")"; }
if($product["mounting"]!="") {
$message .= " (".$product["mounting"].")"; }
$message .= "</font></a></td>";
$message .= "<td align = right><font face=\"MS Sans Serif\" size=2>£".number_format($product["price"], 2) ."</font></td>";
$message .= "<td align = right><font face=\"MS Sans serif\" size=2>".$qty."</font>";
$message .= "</td><td align = right><font face=\"MS Sans Serif\" size=2>£" .number_format($product["price"]*$qty,2). "</font></td></tr>\n";
}
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=3><font face=\"MS Sans Serif\" size=2 color=#666666>Total(Excl VAT & Shipping fees)</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#666666>£".number_format($total_price, 2)."</th></tr>";
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=3><font face=\"MS Sans Serif\" size=2 color=#000>Shipping fees(UK delivery only)</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#000>£".number_format($ukship, 2)."</th></tr>";
$message .= "<th align = left colspan=4><font face=\"MS Sans Serif\" size=1 color=#000>* When the payment is through, the products are in the stock and you place order before 14:00, the products will be delivered the next day between 09:00 - 17:00</th></tr>";
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=3><font face=\"MS Sans Serif\" size=2 color=#000>VAT 17.5%</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#000>£".number_format($tax, 2)."</th></tr>";
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=2><font face=\"MS Sans Serif\" size=2 color=#F2007A>Payment Due</th>";
$message .= "<th align = center><font face=\"MS Sans Serif\" size=2>$items</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#F2007A>£".number_format($grand_total, 2)."</th></tr>";
$message .= "<th align = left><font face=\"MS Sans Serif\" size=2 color=#F2007A>Thank you for shopping with us.</th></tr>";
$message .= "</tr>\n";
$message .= "</td>\n";
$message .= "</body>\n";
$message .= "</html>\n";
}
if (mail($Bcc,'Client Order',$message,$headers)){
# -=-=-=- MAIL HEADERS to Me
$headers .= "Content-Type: text/html; charset=ISO-8859-1 ".$eol;
$headers .= "MIME-Version: 1.0 ".$eol;
$headers .= 'From: Client Order<'.$email.'>'.$eol;
$headers .= 'Reply-To: Client Order<'.$email.'>'.$eol;
$headers .= 'Return-Path: Client Order<'.$email.'>'.$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v" .phpversion().$eol;
# MAIL to Me with product code
# -=-=-=- HTML EMAIL PART
$message .= "<html>\n";
$message .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"default.css\" media=\"screen\">";
$message .= "<link rel=\"stylesheet\" type=\"text/css\" media=\"print\" href=\"print.css\">";
$message .= "$mime_boundary<br>\n\n";
$message .= "ORDER NUMBER: $orderid<br>\n\n";
$message .= "ORDER DATE: $orderdate<br>\n\n";
$message .= "<body style=\"font-family:Verdana, Verdana, Geneva, sans-serif; font-size:14px; color:#666666;\"><br>\n";
$message .= "Dear $ttle\n $fname\n $lname:<br>\n";
$message .= "This email is to confirm that \"We\" have received your order.<br>\n";
$message .= "<font face=\"MS Sans Serif\" size=2 color=#F2007A>Your delivery details:</font><br>\n\n";
$message .= "Address:$addr1, $addr2, <br>\n\n";
$message .= "City: $city<br>\n\n";
$message .= "County: $county<br>\n\n";
$message .= "Country: $country<br>\n\n";
$message .= "Postal Code: $pcode <br>\n\n";
$message .= "Telephone: $phone<br>\n\n";
$message .= "Fax: $fax<br>\n\n";
$message .= "Email: $email<br>\n\n";
$message .= "<font face=\"MS Sans Serif\" size=2 color=#F2007A>Your payment details:</font><br>\n\n";
$message .= "Name on Card: $card_name<br>\n\n";
$message .= "Card Type: $cardType<br>\n\n";
$message .= "Card Number: $cardNumber<br>\n\n";
$message .= "Card Code: $card_code<br>\n\n";
$message .= "Card Expiry: $cardMonth, $cardYear<br>\n\n";
$message .= "<br>\n";
$message .= "<font face=\"MS Sans Serif\" size=2 color=#F2007A>Your ordered items:</font><br>\n\n";
$message .= "<table border=1 cellpadding=0 cellspacing=0 width = 50% bordercolor=#eeeeee align=left>";
$message .= "<tr bordercolor=#CCCCFF bgcolor=#eeeeee align=center>";
$message .= "<th width=50%><h4><div align=center>Product Description</div></h4></th>";
$message .= "<th width=20%><h4><div align=center>Product Code</div></h4></th>";
$message .= "<th width=10%><h4><div align=center>Unit Price</div></h4></th>";
$message .= "<th width=10%><h4><div align=center>Quantity</div></h4></th>";
$message .= "<th width=10%><h4><div align=center>Total Unit Price</div></h4></th>";
$message .= "</tr>";
foreach ($cart as $code => $qty) {
$product = get_product_details($code);
$message .= "<tr>";
$message .= "<td>";
$message .= "<a href = \"www.test.com/price_details.php?code=".$code."\"><font face=\"MS Sans
Serif\" size=2>".$product["name"];
if($product["colour"]!="") {
$message .= " (".$product["colour"].")"; }
if($product["watt"]!="") {
$message .= " (".$product["watt"].")"; }
if($product["lamptype"]!="") {
$message .= " (".$product["lamptype"].")"; }
if($product["mounting"]!="") {
$message .= " (".$product["mounting"].")"; }
$message .= "</font></a></td>";
$message .= "<td align = left><font face=\"MS Sans serif\" size=1>$code</font>";
$message .= "<td align = right><font face=\"MS Sans Serif\" size=2>£".number_format($product["price"], 2) ."</font></td>";
$message .= "<td align = right><font face=\"MS Sans serif\" size=2>".$qty."</font>";
$message .= "</td><td align = right><font face=\"MS Sans Serif\" size=2>£" .number_format($product["price"]*$qty,2). "</font></td></tr>\n";
}
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=4><font face=\"MS Sans Serif\" size=2 color=#666666>Total(Excl VAT & Shipping fees)</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#666666>£".number_format($total_price, 2)."</th></tr>";
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=4><font face=\"MS Sans Serif\" size=2 color=#000>Shipping fees(UK delivery only)</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#000>£".number_format($ukship, 2)."</th></tr>";
$message .= "<th align = left colspan=4><font face=\"MS Sans Serif\" size=1 color=#000>* When the payment is through, the products are in the stock and you place order before 14:00, the products will be delivered the next day between 09:00 - 17:00</th></tr>";
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=4><font face=\"MS Sans Serif\" size=2 color=#000>VAT 17.5%</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#000>£".number_format($tax, 2)."</th></tr>";
$message .= "<tr bgcolor=#FFFFFF>";
$message .= "<th align = left colspan=3><font face=\"MS Sans Serif\" size=2 color=#F2007A>Payment Due</th>";
$message .= "<th align = center><font face=\"MS Sans Serif\" size=2>$items</th>";
$message .= "<th align = right><font face=\"MS Sans Serif\" size=2 color=#F2007A>£".number_format($grand_total, 2)."</th></tr>";
$message .= "<th align = left colspan=4><font face=\"MS Sans Serif\" size=2 color=#F2007A>Thank you for shopping with us.</th></tr>";
$message .= "</tr>\n";
$message .= "</td>\n";
$message .= "</body>\n";
$message .= "</html>\n";
}
# -=-=-=- SEND MAIL
mail ("$email","Order",$message,$headers);
mail("$Bcc","Client Order",$message,$headers);
echo '<META HTTP-EQUIV="REFRESH" CONTENT="1;URL=http://www.test.com/thanks.html">';feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]