/    Sign up×
Community /Pin to ProfileBookmark

Part of email script not working

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);
?>
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYOct 02.2005 — try echoing the $email variable just after defining it, line 13
Copy linkTweet thisAlerts:
@summit310authorOct 02.2005 — Hi,

I did echo the $email variable and it's coming through. It would need to because my second email which is sent to the retailer has the result of the $email variable in the From: part of the email.
×

Success!

Help @summit310 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...