hello everybody....i feel like such an idiot that i can't get this right, but basically i am just wanting to loop through the table LOGIN and send each "email_login" field this templated database.
I have about 1500 records in the database and it keeps timing out.....and i have no idea how far it gets...
help!
<?php
$db = mysql_connect("localhost", ".....", "......");
mysql_select_db(".......",$db);
$query = mysql_query("SELECT * from login");
$num = mysql_num_rows($query);
for ($i=0; $i<$num; $i++) {
$a = mysql_fetch_array($query);
$to = $a["email_login"];
$from = "management@......com";
$subject = "subject";
$mailheaders = "From: $from\n";
$mailheaders .= "Reply-To: $from\n\n";
$body = "Hello everybody,\n
MESSAGE
";
stripslashes($body);
strip_tags($body);
stripslashes($subject);
strip_tags($subject);
stripslashes($mailheaders);
strip_tags($mailheaders);
mail("$to", "$subject", "$body", "$mailheaders");
echo "sending to ".$to."";
sleep(1);
}
echo "all your emails were sent";
?>
should i use a foreach loop? how can i run this from command line so it doesn't time out?
-Michael