PDA

View Full Version : select multiple emails from database & let them know expiry date


nanny
04-28-2008, 04:00 AM
Hi I am wanting to do something similar to another post where by selecting listings that are due to expire to alert them and also listings that have expired and not renewed and alert them it is being deleted and then delete them automatically.
Now I was thinking there must be another way than this:



$query = sprintf("SELECT email FROM listing WHERE ((TO_DAYS(CURDATE()) - TO_DAYS(expiry)) > 60)"; ");
$results = mysql_query($query);
$row = mysql_fetch_array($results);



$addresses = array("$row['email'];");
$to = me@email.com.au;
$subject = "PHP Newsletter";
$message = "This e-mail shows how to use a BCC Header to send a
newsletter";
$headers .= "From: me<me@email.com.au\n";
$headers .= "bcc: ";
$count = 0;
foreach($addresses as $address){
if($count == 0){
$headers .= $address
}else{
$headers .= ", " . $address
}$count ++;
}
[$headers .= "\n";
mail($to, $subject, $message, $headers);
?





<?php set_time_limit(5*60); ?>



Once I have selected the correct list then I am stuck. They will be shown as a repeat region, but how do I get them to email or is it best to try and do a cron job?
Thanks for your help.

davidj
04-28-2008, 12:38 PM
write a script which checks and emails any found

run this on a cron every week or so