I have a mySQL database that has about 1500 contacts in it and I want to be able to send an email to all of them by pushing a button on a web page. I actually have a working version, but I need to solve 2 issues:
1) I need to limit the output to 300 emails/hour to avoid triggering a spam alarm on my web-host.
2) I want the script to run without a browser window being open.
Right now, the user presses a submit button on a form which loads a new PHP webpage which sends all the emails. The server only sends about 1 email/second so the webpage has to remain open for at least 1500 seconds or else the script will terminate without completing. So basically I want to the user to press the submit button on the form and have a script triggered that sends the emails behind the scenes without the need to keep a browser window open. Ideally, the user would then be directed to another page letting he/she know that the emails would be sent at a rate of 300 emails/hour.
Here's the important part of code (if seeing any more of it would help let me know):
<?php
$db = mysql_connect("mysite.web.aplus.net", "username", "password");
mysql_select_db("username",$db);
$result = mysql_query("SELECT * FROM VP_mail WHERE $list='1'",$db);
while ($myrow = mysql_fetch_row($result))
{
mail("$myrow[2]","$subject","$message","From: $from <$retadd>");
}
}
?>
What do you think I should use to do this?