由于某种原因,不会向管理员发送邮件,也称为'carparks_accounts',任何人都可以帮我这个吗?将这封电子邮件从一封电子邮件中作为SMTP发送是不是更明智?如果是这样我怎么办?听众会有问题吗?
<?php
$link = mysql_connect("mysql", "", "");
if(!$link) {
die('Couldnt Connect To Server: ' . mysql_error());
}
$db = mysql_select_db("");
if(!$db) {
die("Couldnt Connect To Database");
}
$sql6 = "UPDATE `discount_type` SET `name`='READ' WHERE `id`='1'";
$results1 = mysql_query($sql6);
// read the post from PayPal system and add 'cmd'
$req = 'cmd=' . urlencode('_notify-validate');
foreach ($_POST as $key => $value) {
if (!is_array($value)) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
else if (is_array($value)) {
$paymentArray = explode(' ', $value[0]);
$paymentCurrency = urlencode(stripslashes($paymentArray[0]));
$paymentGross = urlencode(stripslashes($paymentArray[1]));
$req .= '&mc_currency=' . $paymentCurrency . '&mc_gross=' . $paymentGross;
}
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: www.paypal.com'));
$res = curl_exec($ch);
curl_close($ch);
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$custom = $_POST['custom'];
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$sql6 = "UPDATE `discount_type` SET `name`='YES".$custom."' WHERE `id`='1'";
$results1 = mysql_query($sql6);
$bid = $custom;
$sql1=mysql_query("SELECT * FROM `bookings` WHERE `id`='".$bid."'");
$row1=mysql_fetch_assoc($sql1);
$sql2=mysql_query("SELECT * FROM `users` WHERE `id`='".$row1['uid']."'");
$row2=mysql_fetch_assoc($sql2);
$sql3=mysql_query("SELECT * FROM `users_address` WHERE `uid`='".$row1['uid']."'");
$row3=mysql_fetch_assoc($sql3);
$sql4=mysql_query("SELECT * FROM `users_vehicles` WHERE `uid`='".$row1['uid']."'");
$row4=mysql_fetch_assoc($sql4);
$sql5=mysql_query("SELECT * FROM `carparks_content` WHERE `cpid`='".$row1['cpid']."'");
$row5=mysql_fetch_assoc($sql5);
$sql8=mysql_query("SELECT * FROM `bookings_details` WHERE `bid`='".$bid."'");
$row8=mysql_fetch_assoc($sql8);
$sql9=mysql_query("SELECT * FROM `carparks` WHERE `id` = '".$tow1['cpid']."'");
$row9=mysql_fetch_assoc($sql8);
$to = $row2['email'];
$subject = "SpeedyPark Booking Confirmation";
$message = "<p>Hi, ".$row2['fname']."</p>";
$message .= "<p>Thank you for booking your airport parking with SpeedyPark.</p>";
$message .= "<p>Booking REF: <b>".$row9['uniqueRef'].str_pad ( $bid , 7 ,"0", STR_PAD_LEFT )."</b></p>";
$message .= "<p>Name: <b>".$row2['fname']." ".$row2['sname']."</b></p>";
$message .= "<p>Drop Off Dates: <b>".date('d/m/Y', $row1['sdate'])." - ".$row1['stime']."</b></p>";
$message .= "<p>Pick Up Dates: <b>".date('d/m/Y', $row1['edate'])." - ".$row1['etime']."</b></p>";
$message .= "<p>Outbound Flight: <b>Terminal ".$row8['terminalout']." - Flight ".$row8['flightout']."</b></p>";
$message .= "<p>Return Flight: <b>Terminal ".$row8['terminalin']." - Flight ".$row8['flightin']."</b></p>";
$message .= "<p>Price: <b>".$row1['price']."</b></p>";
$message .= "<p>Phone: <b>".$row2['phone']."</b></p>";
$message .= "<p>Email: <b>".$row2['email']."</b></p>";
$message .= "<p>Address: <b>".$row3['address1'].", ".$row3['address2'].", ".$row3['city'].",".$row3['postcode']."</b></p>";
$message .= "<p>Vehicle: <b>".$row4['reg']." - ".$row4['make']." ".$row4['model']." - ".$row4['colour']."</b></p>";
if ($row1['cpeid'] == "") {
} else {
$message .= "<h3>Extras</h3>";
$extralist = explode(', ', $row1['cpeid']);
foreach($extralist as $value) //loop over values
{
$sql17 = mysql_query("SELECT * FROM `carparks_extras` WHERE `id`='".$value."'");
$row17 = mysql_fetch_assoc($sql7);
$message .= $row17['name']."<br/>";
}
}
if ($row5['directions'] == "") { } else {
$message .= "<h3>Directions</h3>";
$message .= $row5['directions'];
}
if ($row5['arrival'] == "") { } else {
$message .= "<h3>Arrival</h3>";
$message .= $row5['arrival'];
}
if ($row5['departure'] == "") { } else {
$message .= "<h3>Departure</h3>";
$message .= $row5['departure'];
}
if ($row5['transfers'] == "") { } else {
$message .= "<h3>Transfer</h3>";
$message .= $row5['transfers'];
}
$headers = "From: reservation@speedypark.co.uk \r\n";
$headers .= "Reply-To: reservation@speedypark.co.uk \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $message, $headers);
$sql9=mysql_query("SELECT * FROM `carparks_accounts` WHERE `cpid`='".$row1['cpid']."'");
$row9=mysql_fetch_assoc($sql9);
$to2 = $row9['email'];
$subject2 = "New Airport Parking Booking Confirmation";
$message2 .= "<p>Your car park has received a new booking through SpeedyPark.</p>";
$message2 .= "<p>Booking ID: <b>".$bid."</b></p>";
$message2 .= "<p>Name: <b>".$row2['fname']." ".$row2['sname']."</b></p>";
$message2 .= "<p>Drop Off Dates: <b>".date('d/m/Y', $row1['sdate'])." - ".$row1['stime']."</b></p>";
$message2 .= "<p>Pick Up Dates: <b>".date('d/m/Y', $row1['edate'])." - ".$row1['etime']."</b></p>";
$message2 .= "<p>Outbound Flight: <b>Terminal ".$row8['terminalout']." - Flight ".$row8['flightout']."</b></p>";
$message2 .= "<p>Return Flight: <b>Terminal ".$row8['terminalin']." - Flight ".$row8['flightin']."</b></p>";
$message2 .= "<p>Price: <b>".$row1['price']."</b></p>";
$message2 .= "<p>Vehicle: <b>".$row4['reg']." - ".$row4['make']." ".$row4['model']." - ".$row4['colour']."</b></p>";
if ($row1['cpeid'] == "") {
} else {
$message2 .= "<h3>Extras</h3>";
$extralist = explode(', ', $row1['cpeid']);
foreach($extralist as $value) //loop over values
{
$sql17 = mysql_query("SELECT * FROM `carparks_extras` WHERE `id`='".$value."'");
$row17 = mysql_fetch_assoc($sql7);
$message2 .= $row17['name']."<br/>";
}
}
$headers2 = "From: reservation@speedypark.co.uk \r\n";
$headers2 .= "Reply-To: reservation@speedypark.co.uk \r\n";
$headers2 .= "MIME-Version: 1.0\r\n";
$headers2 .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to2, $subject2, $message2, $headers2);
$sql6 = "UPDATE `bookings` SET `status`='confirmed' WHERE `id`='".$bid."'";
$results1 = mysql_query($sql6);
}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
$sql6 = "UPDATE `discount_type` SET `name`='NO' WHERE `id`='1'";
$results1 = mysql_query($sql6);
}
?>