Page 1 of 1

Email portion of script not working

Posted: Sun Oct 02, 2005 5:00 am
by summitweb
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


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: Select all

<?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*/ 

$to = "<" . $email .">"; --- this is the problem area. This email is not being sent./* 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.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "From: <retailer email address>\r\n"; 
$headers .= "X-Mailer: PHP / ".phpversion()."\r\n"; 

/* mail it */ 
mail($to, $subject, $message, $headers); 

//confirmation being sent to retailer -- this email does work

$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.0\r\n"; 
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
$headers .= "From: <$email>\r\n"; 
$headers .= "X-Mailer: PHP / ".phpversion()."\r\n"; 

/* mail it */ 
mail($to, $subject, $message, $headers); 
?>

feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sun Oct 02, 2005 7:56 am
by shiznatix
try just making $to = $email

i never saw anyone put the <> in the to email before but if that does not work check your spam settings. it might be getting caught in those

Posted: Sun Oct 02, 2005 8:08 am
by summitweb
Hello:

I changed my statement as you suggested: $to=$email and I'm getting the same result - no email is being sent.

Posted: Sun Oct 02, 2005 8:21 am
by shiznatix
what about this line here

$to = "<retailer email address>";

do you actually put in a email address there?

Posted: Sun Oct 02, 2005 8:29 am
by summitweb
Yes, in the following statement:

$to = "<retailer email address>";

I do put an email address. The statement actually would appear as:

$to = "<jane.doe@comcast.net>";

Jane Doe does receive an email from John Doe, example of value for $email variable, showing his information. But, John Doe does not receive an email from Jane Doe which shows the detail of his information.