Ordremail med smtp.php forbindelse
Jeg har problemer med min ordremail der skulle have forbindelse med smtp.php forbindelse.Efter en kunder har godkendt sin bestilling kommer der en ordre oversigt, men den siger serverfejl: Warning: Server Error in D:\ateamweb\k_site\kalaaleq.gl\www.kalaaleq.gl\pisi\vsadmin\inc\incthanks.php on line 107
Jeg havde det samme problem med "email to a friend" men blev løst af zeled. Tak til zeled. Spørgsmållink: http://www.eksperten.dk/spm/399362
Dvs. incthanks.php skal også have denne smtp.php forbindelse.
Hvordan gør jeg ?
Jeg paste'r lige koderne:
<?php
function do_stock_management($smOrdId){
global $stockManage;
if($stockManage != 0){
$sSQL="SELECT cartProdID, cartQuantity FROM cart WHERE cartCompleted=0 AND cartOrderID=" . $smOrdId;
$result = mysql_query($sSQL) or print(mysql_error());
while($rs = mysql_fetch_array($result)){
$sSQL = "UPDATE products SET pInStock=pInStock-" . $rs["cartQuantity"] . " WHERE pID='" . $rs["cartProdID"] . "'";
mysql_query($sSQL) or print(mysql_error());
}
mysql_free_result($result);
}
}
function order_success($sorderid,$sEmail,$bSendEmail){
global $maintablebg,$innertablebg,$maintablewidth,$innertablewidth,$maintablespacing,$innertablespacing,$maintablepadding,$innertablepadding;
global $xxOrdId,$xxCusDet,$xxEmail,$xxPhone,$xxShpDet,$xxShpMet,$xxAddInf,$xxPrId,$xxPrNm,$xxQuant,$xxUnitPr,$xxOrdTot,$xxStaTax,$xxCntTax,$xxShippg,$xxGndTot,$xxOrdStr,$xxTnxOrd,$xxTouSoo,$xxAff1,$xxAff2,$xxAff3,$xxThnks,$xxThkYou,$xxRecEml,$xxHomeURL,$xxCntShp;
$affilID = "";
$sSQL = "SELECT ordID,ordName,ordAddress,ordCity,ordState,ordZip,ordCountry,ordEmail,ordPhone,ordShipName,ordShipAddress,ordShipCity,ordShipState,ordShipZip,ordShipCountry,ordPayProvider,ordAuthNumber,ordTotal,ordDate,ordStateTax,ordCountryTax,ordShipping,ordAffiliate,ordAddInfo,ordShipType FROM orders LEFT JOIN payprovider ON payprovider.payProvID=orders.ordPayProvider WHERE ordID=" . $sorderid;
$result = mysql_query($sSQL) or print(mysql_error());
if(mysql_num_rows($result) > 0){
$rs = mysql_fetch_assoc($result);
$orderText = $xxOrdId . ": " . $rs["ordID"] . "<br>\r\n";
$orderText .= $xxCusDet . ": " . "<br>";
$orderText .= $rs["ordName"] . "<br>";
$orderText .= $rs["ordAddress"] . "<br>";
$orderText .= $rs["ordCity"] . ", " . $rs["ordState"] . "<br>";
$orderText .= $rs["ordZip"] . "<br>";
$orderText .= $rs["ordCountry"] . "<br>\r\n";
$orderText .= $xxEmail . ": " . $rs["ordEmail"] . "<br>";
$custEmail = $rs["ordEmail"];
$orderText .= $xxPhone . ": " . $rs["ordPhone"] . "<br>";
if(trim($rs["ordShipName"]) != "" || trim($rs["ordShipAddress"]) != ""){
$orderText .= $xxShpDet . ": " . "<br>";
$orderText .= $rs["ordShipName"] . "<br>";
$orderText .= $rs["ordShipAddress"] . "<br>";
$orderText .= $rs["ordShipCity"] . ", " . $rs["ordShipState"] . "<br>";
$orderText .= $rs["ordShipZip"] . "<br>";
$orderText .= $rs["ordShipCountry"] . "<br>\r\n";
}
$ordShipType = $rs["ordShipType"];
if($ordShipType != "")
$orderText .= "<br>" . $xxShpMet . ": " . $ordShipType . "<br>";
$ordAddInfo = trim($rs["ordAddInfo"]);
if($ordAddInfo != ""){
$orderText .= "<br>" . $xxAddInf . ": " . "<br>\r\n";
$orderText .= $ordAddInfo . "<br>\r\n";
}
$ordTotal = $rs["ordTotal"];
$ordDate = $rs["ordDate"];
$ordStateTax = $rs["ordStateTax"];
$ordCountryTax = $rs["ordCountryTax"];
$ordShipping = $rs["ordShipping"];
$affilID = trim($rs["ordAffiliate"]);
}else{
$orderText = "Cannot find customer details<br>";
}
mysql_free_result($result);
$sSQL = "SELECT cartProdId,cartProdName,cartProdPrice,cartQuantity,cartID FROM cart WHERE cartOrderID=" . $sorderid;
$result = mysql_query($sSQL) or print(mysql_error());
if(mysql_num_rows($result) > 0){
while($rs = mysql_fetch_assoc($result)){
$orderText .= "--------------------------" . "<br>\r\n";
$orderText .= $xxPrId . ": " . $rs["cartProdId"] . "<br>\r\n";
$orderText .= $xxPrNm . ": " . $rs["cartProdName"] . "<br>\r\n";
$orderText .= $xxQuant . ": " . $rs["cartQuantity"] . "<br>\r\n";
$orderText .= $xxUnitPr . ": " . FormatEmailEuroCurrency($rs["cartProdPrice"]) . "<br>\r\n";
$optPriceDiff=0;
$sSQL = "SELECT coOptGroup,coCartOption,coPriceDiff FROM cartoptions WHERE coCartID=" . $rs["cartID"];
$result2 = mysql_query($sSQL) or print(mysql_error());
while($rs2 = mysql_fetch_assoc($result2)){
$orderText .= " > " . $rs2["coOptGroup"] . " : " . $rs2["coCartOption"];
if($rs2["coPriceDiff"]==0)
$orderText .= "<br>";
else{
$orderText .= " (";
if($rs2["coPriceDiff"] > 0) $orderText .= "+"; else $orderText .= "-";
$orderText .= FormatEmailEuroCurrency($rs2["coPriceDiff"]) . ")" . "<br>\r\n";
}
}
mysql_free_result($result2);
}
$orderText .= "--------------------------" . "<br>\r\n";
$orderText .= $xxOrdTot . " : " . FormatEmailEuroCurrency($ordTotal) . "<br>\r\n";
$orderText .= $xxStaTax . " : " . FormatEmailEuroCurrency($ordStateTax) . "<br>\r\n";
$orderText .= $xxCntTax . " : " . FormatEmailEuroCurrency($ordCountryTax) . "<br>\r\n";
$orderText .= $xxShippg . " : " . FormatEmailEuroCurrency($ordShipping) . "<br>\r\n";
$orderText .= $xxGndTot . " : " . FormatEmailEuroCurrency($ordTotal+$ordStateTax+$ordCountryTax+$ordShipping) . "<br>\r\n";
}else{
$orderText .= "Cannot find order details" . "<br>";
}
mysql_free_result($result);
if($bSendEmail){
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $sEmail . " <" . $sEmail . ">\r\n";
$headers .= "To: " . $sEmail . " <" . $sEmail . ">\r\n";
mail($sEmail, $xxOrdStr, $orderText, $headers);
}
// And one for the customer
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $sEmail . " <" . $sEmail . ">\r\n";
$headers .= "To: " . $custEmail . " <" . $custEmail . ">\r\n";
mail($custEmail, $xxTnxOrd, $xxTouSoo . "<br><br>" . $orderText, $headers);
if($affilID != ""){
$sSQL = "SELECT affilEmail,affilInform FROM affiliates WHERE affilID='" . mysql_escape_string($affilID) . "'";
$result = mysql_query($sSQL) or print(mysql_error());
if($rs = mysql_fetch_assoc($result)){
if((int)$rs["affilInform"]==1){
$affiltext = $xxAff1 . " " . FormatEmailEuroCurrency($ordTotal) . ".<br><br>".$xxAff2."<br><br>".$xxThnks."<br>";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $sEmail . " <" . $sEmail . ">\r\n";
$headers .= "To: " . trim($rs["affilEmail"]) . " <" . trim($rs["affilEmail"]) . ">\r\n";
mail(trim($rs["affilEmail"]), $xxAff3, $affiltext, $headers);
}
}
mysql_free_result($result);
}
?>
<table border="0" cellspacing="<?php print $maintablespacing?>" cellpadding="<?php print $maintablepadding?>" width="<?php print $maintablewidth?>" bgcolor="<?php print $maintablebg?>" align="center">
<tr>
<td width="100%">
<table width="<?php print $innertablewidth?>" border="0" cellspacing="<?php print $innertablespacing?>" cellpadding="<?php print $innertablepadding?>" bgcolor="<?php print $innertablebg?>">
<tr>
<td width="100%" align="center"><?php print $xxThkYou?>
</td>
</tr>
<tr>
<td width="100%"><?php print str_replace(" "," ",$orderText)?>
</td>
</tr>
<tr>
<td width="100%" align="center"><br><br>
<?php print $xxRecEml?><br><br>
<a href="<?php print $xxHomeURL?>"><b><?php print $xxCntShp?></b></a><br>
<img src="images/clearpixel.gif" width="350" height="3">
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
function order_failed(){
global $maintablebg,$innertablebg,$maintablewidth,$innertablewidth,$maintablespacing,$innertablespacing,$maintablepadding,$innertablepadding;
global $xxThkErr,$xxHomeURL,$xxCntShp;
?>
<table border="0" cellspacing="<?php print $maintablespacing?>" cellpadding="<?php print $maintablepadding?>" width="<?php print $maintablewidth?>" bgcolor="<?php print $maintablebg?>" align="center">
<tr>
<td width="100%">
<table width="<?php print $innertablewidth?>" border="0" cellspacing="<?php print $innertablespacing?>" cellpadding="<?php print $innertablepadding?>" bgcolor="<?php print $innertablebg?>">
<tr>
<td width="100%" colspan="2" align="center"><?php print $xxThkErr?>
<a href="<?php print $xxHomeURL?>"><b><?php print $xxCntShp?></b></a><br>
<img src="images/clearpixel.gif" width="350" height="3">
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
$sSQL="SELECT adminEmail,adminEmailConfirm,countryLCID,countryCurrency,adminStockManage FROM admin LEFT JOIN countries ON admin.adminCountry=countries.countryID WHERE adminID=1";
$result = mysql_query($sSQL) or print(mysql_error());
$rs = mysql_fetch_array($result);
$emailAddr = $rs["adminEmail"];
$sendEmail = ((int)$rs["adminEmailConfirm"]==1);
$adminLocale = $rs["countryLCID"];
$useEuro = ($rs["countryCurrency"]=="EUR");
$stockManage = (int)$rs["adminStockManage"];
mysql_free_result($result);
if(@$_POST["custom"] != ""){
order_success(@$_POST["custom"],$emailAddr,$sendEmail);
}elseif(@$_POST["cart_order_id"] != "" && @$_POST["order_number"] != ""){ // 2Checkout Transaction
if(trim(@$_POST["credit_card_processed"])=="Y"){
do_stock_management(trim(@$_POST["cart_order_id"]));
$sSQL="UPDATE cart SET cartCompleted=1 WHERE cartOrderID=" . trim(@$_POST["cart_order_id"]);
mysql_query($sSQL) or print(mysql_error());
$sSQL="UPDATE orders SET ordAuthNumber='" . trim(@$_POST["order_number"]) . "' WHERE ordID=" . trim(@$_POST["cart_order_id"]);
mysql_query($sSQL) or print(mysql_error());
order_success(@$_POST["cart_order_id"],$emailAddr,$sendEmail);
}else{
order_failed();
}
}elseif(@$_POST["emailorder"] != ""){
do_stock_management(trim(@$_POST["emailorder"]));
$sSQL="UPDATE cart SET cartCompleted=1 WHERE cartOrderID=" . trim(@$_POST["emailorder"]);
mysql_query($sSQL) or print(mysql_error());
$sSQL="UPDATE orders SET ordAuthNumber='Email Only' WHERE ordID=" . trim(@$_POST["emailorder"]);
mysql_query($sSQL) or print(mysql_error());
order_success(@$_POST["emailorder"],$emailAddr,$sendEmail);
}else{
order_failed(); // If not match any
}
?>