I’m trying to send an email to everyone from a database list. I have attached the code. For some reason this code never sends the emails out. It only works if the $to variable is set to one person and one person only.
$to = "matthew.oconnor@comcast.net";
but here is the code that doesn’t work. Any hints?
<?php
mysql_select_db($database_connPavlishDB, $connPavlishDB);
$query_rsSpecials1 = "SELECT * FROM specials";
$rsSpecials1 = mysql_query($query_rsSpecials1, $connPavlishDB) or die(mysql_error());
$row_rsSpecials1 = mysql_fetch_assoc($rsSpecials1);
$totalRows_rsSpecials1 = mysql_num_rows($rsSpecials1);
mysql_select_db($database_connPavlishDB, $connPavlishDB);
$query_rsEmails = "SELECT * FROM customers";
$rsEmails = mysql_query($query_rsEmails, $connPavlishDB) or die(mysql_error());
$row_rsEmails = mysql_fetch_assoc($rsEmails);
$totalRows_rsEmails = mysql_num_rows($rsEmails);
?>
<?php $var1 = "Here are the current specials at Pavlish Beverage.
"?>
<?php do { ?>
<?php
$var1 .= $row_rsSpecials1['name'];
$var1 .= " ";
$var1 .= $row_rsSpecials1['quantity'];
$var1 .= " for ";
$var1 .= $row_rsSpecials1['price'];
$var1 .= ".
"
?>
<?php } while ($row_rsSpecials1 = mysql_fetch_assoc($rsSpecials1)); ?>
<?php $var1 .= "
Have A Good 1!
Pavlish Beverage
(610)866-7722
http://www.PavlishBev.com" ?>
<?php do { ?>
<?php
$var2 = $row_rsEmails['email'];
$var2 .= ",
";
?>
<?php } while ($row_rsEmails = mysql_fetch_assoc($rsEmails)); ?>
<?php
$to = "$var2";
$subject = "Pavlish Beverage Alert!";
$message = "$var1";
mail($to,$subject,$message);
?>