If you know how, try to make the script control itself, like have it be controlled by a cronjob, run once an hour (or whatever the limit would be, you can ask your host on what thier limit is before blacklisting you). It could retrieve, say, 20 (I would start small until you talk to your host about the topic), and have it pull the first 20 entries from your database, then have a way of storing where on the list the script is, such as in a .txt file or in the database. Then, the next time the cron job activates the script, it will pull that last result set from that .txt file etc, and continue from there.
Simple example.
// Variables
$subject = 'Your Subject';
$message = wordwrap('Your Message', 70); // Just read up that lines cannot be longer than 70 characters, so just to make sure if your message is long, use wordwrap()
$headers = 'From: you@yoursite.com' . "\r\n" .
'Reply-To: you@yoursite.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$emails_limit = 20; // How many emails to send each time script is run
$start = (int)file_get_contents('mail_counter.txt'); // Get last results sent
// Grab Emails and Send
$get_emails = mysql_query("SELECT `email` FROM `members` LIMIT $start, $emails_limit") or die(mysql_error());
while($e = mysql_fetch_array($get_emails)) mail($e['email'], $subject, $message, $headers);
// Open Counter and Increment
$counter = fopen('mail_counter.txt', 'w+');
$results = mysql_num_rows($get_emails);
fwrite($counter, (($results > 0) ? $start + $results : 0)); // Either increment by number of rows returned, or start back at 0 if we've reached the end of all emails to be sent
fclose($counter);
I think you should read up on this page, it talks about using PEAR for mass emailing, and I don't know squat about PEAR, so can't help much there.
PHP Mail Function
Edited by Demonslay, 01 January 2007 - 11:59 AM.