yeah, most web apps that do stuff like this will send 10-100 emails at a time. you could store the count of the email addresses in a session variable and then use a meta refresh on the page to only send x number of emails at a time. when you print the meta refresh, it will print a GET variable of where to start.
for example, your script maybe: mymailer.php .. so this script will first query the db for the total number of email addresses, store it in a session variable, send out the first 10 emails, and then print a meta refresh with a start variable incremented by 10.
here's some example psuedo code that is untested and not meant for use:
PHP Code:
<?php
// start the session
session_start();
// set how many emails you want to send per page
$limit = 20;
// if the count has not been set, then let's set it
if (!$_SESSION['count']) {
$result = mysql_query("select count(*) from users");
$_SESSION['count'] = mysql_result($result,0,0);
// since we wouldn't have run this before, let's
// set the starting point. later this will be set in the url
$_GET['start'] = 1;
}
// now we wil run the query with the start and limit vars
$result = mysql_query("select email from users limit ".$_GET['start'].", ".$limit);
while ($row= mysql_fetch_assoc($result)) {
// send out the email here
// maybe echo the people getting emailed here too
}
// now lets print out a meta refresh to the browser so
// the page will refresh and query a new set of results.
// only do this if we haven't reached the end yet.
if ($_GET['start']+$limit < $_SESSION['count']) {
echo '<meta http-equiv="refresh" content="2;url=mymailer.php?start='.$_GET['start']+$limit.'">';
} else {
echo "Mail complete";
}
?>