I'm not sure how you want to do this, but here's a way to email people from a mysql database...
The key feature is set_time_limit() that way the script has enough time to complete the process..
here's the example:
<?php
set_time_limit(999999);
$title = "My TITLE!";
$msg = "Email Message.";
$headers = "From: Somewhere@someplace.com\r\nReply-To: Somewhere@someplace.com";
$dbh = mysql_connect("somewhere", "user", "pass");
mysql_select_db("database", $dbh);
$query = mysql_query("SELECT UNIQUE/DISTINCT email_address_column_name FROM somewhere") or die(mysql_error());
$i = 0;
while($row = mysql_fetch_array($query))
{
$i++;
mail($row['email'], $title, $msg, $headers);
echo "Message number $i sent.\n<br />\n";
}
echo "Mass Mailing Done.";
?>