Hello:
I’m running a script which sends two emails: the first goes to the customer and the second goes to the retailer.
The email going to the customer is the problem. Though, the email going to the retailer from the customer does work.
For whatever reason, the variable $to for the customer email isn’t reading the customer’s email address. Yet, the email going to the retailer which has the customer’s email address does read in the $from variable.
I can’t seem to figure out why one email is being sent and the other isn’t. Can someone help me out?
Thank you in advance.
Here is the code:
[code]
<?php
session_start();
//connect to the database – either include a connection variable file
//or type the following lines:
$conn = mysql_connect(“host”, “user”, “pw”) or die (mysql_error());
mysql_select_db(“db”) or die(mysql_error());
//Let’s make the variables easy to access in our queries
$firstname = $_SESSION[‘firstname’];
$lastname = $_SESSION[‘lastname’];
$firstname = $_SESSION[‘firstname’];
$email = $_SESSION[’email’];
//1) Insert Info into table
//find the correct cart information being temporarily stored
$query = “SELECT * FROM carttemp WHERE carttemp_sess=’$sessid'”;
$results = mysql_query($query) or die(mysql_error());
//put the data into the database one row at a time
while ($row = mysql_fetch_array($results)) {
extract($row);
$query4 = “INSERT INTO orderdet (
orderdet_ordernum, orderdet_qty, orderdet_prodnum, orderdet_prodname, orderdet_color, orderdet_price)
VALUES (
‘$orderid’,
‘$carttemp_qty’,
‘$carttemp_prodnum’, ‘$carttemp_prodname’, ‘$carttemp_color’, ‘$carttemp_price’)”;
$insert4 = mysql_query($query4) or die(mysql_error());
}
//5)email confirmations to us and to the customer
/* recipients – customer who placed the order*/
[B][COLOR=Red]$to = “<” . $email .”>”; — this is the problem area. This email is not being sent.[/COLOR] [/B]
/* subject */
$subject = “Order Confirmation”;
/* message */
/* top of message */
$message = ”
<html>
<head>
<title>Order Confirmation</title>
</head>
<body>
<font face=”Verdana” size=”2″>Thank you for shopping The Blue Hydrangea. Your order is currently being processed. Here are the details of your order:<br><br>
<b>Order Date:</b> “;
$message .= $today;
$message .= ”
<br>
<b>Order Number:</b> “;
$message .= $orderid;
$message .= “<br><br>”;
$message .= ”
<table width=”50%” border=”0″>
<tr>
<td>
</td>
</tr>
</table>
</body>
</html>”;
/* headers */
$headers = “MIME-Version: 1.0rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= “From: <retailer email address>rn”;
$headers .= “X-Mailer: PHP / “.phpversion().”rn”;
/* mail it */
mail($to, $subject, $message, $headers);
[B]//[COLOR=Red]confirmation being sent to retailer — this email does work[/COLOR] [/B]
$to = “<retailer email address>”;
/* subject */
$subject = “Order Confirmation”;
/* message */
/* top of message */
$message = ”
<html>
<head>
<title>Order Confirmation</title>
</head>
<body>
<font face=”Verdana” size=”2″>The following order was placed by $firstname $lastname”;
$message .= ”
<br><br>
<b>Order Date:</b> “;
$message .= $today;
$message .= ”
<br><br>
<b>Order Number:</b> “;
$message .= $orderid;
$message .= “<br><br>”;
$message .= ”
<table width=”50%” border=”0″>
<tr>
<td>
</td>
</tr>
</table>
</body>
</html>”;
/* headers */
$headers = “MIME-Version: 1.0rn”;
$headers .= “Content-type: text/html; charset=iso-8859-1rn”;
$headers .= “From: <$email>rn”;
$headers .= “X-Mailer: PHP / “.phpversion().”rn”;
/* mail it */
mail($to, $subject, $message, $headers);
?>