On Tue, May 2, 2006 6:16 am, Ryan A wrote: > The problem is the host is limiting the amount of > emails that can go from the site per minute, and we > need to email all the members (a modest 700 or so) a > newsletter/update...any suggestions on how to do that? The main problem with using mail() for mass emails is that every call to mail() fires up sendmail, and you can easily swamp your machine. If the host won't let you do more than X per minute, and you write a loop to stay within that limit (http://php.net/sleep) then you should probably be okay. I wouldn't want to do it for THOUSANDS of emails, but you're probably going to run into time-delay problems of the mail not being relevant because of the server-enforced limits before anything else. I had to do this once for a client, and I'll just paste my code here. It's crude in many ways, as I don't really know ADOdb well enough to remember the darn function names, but didn't want to write a second 'connect' script, so I sort of use ADO to connect, and then ignore ADO. <?php require_once 'lib/common/Init.inc'; $init = new Init; $db = $init->getAdoDbConnection(); $dbconn = $init->getAdoDbConnection(); require 'email_message.php'; $message_object = new email_message_class(); $query = "select mail_id, subject, plain, html from mail "; $query .= " where autosend "; $query .= " and send_date <= now() "; $query .= " and sent_date is null "; $result = mysql_query($query) or die("Error in query: $query. " . mysql_error()); $errors = ''; $from = '"Example" <nobody@xxxxxxxxxxx>'; #$errors .= $message_object->SetHeader('Return-Path', $from); $errors .= $message_object->SetHeader('From', $from); $errors .= $message_object->SetHeader('Reply-to', $from); $query = "select email from user where newsletter order by reverse(email) "; $victims = mysql_query($query) or die("Error in query: $query. " . mysql_error()); //Policies dictate no more than 50 messages per minute, nor 500 per hour $start = time(); $counter = 0; while (list($mail_id, $subject, $plain, $html) = mysql_fetch_row($result)){ $errors .= $message_object->AddPlainTextPart($plain); $errors .= $message_object->AddHTMLPart($html); $errors .= $message_object->SetHeader('Subject', $subject); mysql_data_seek($victims, 0); while (list($victim) = mysql_fetch_row($victims)){ $errors .= $message_object->SetHeader('To', $victim); if (1){ $errors .= $message_object->Send(); } else{ echo "<pre>"; ob_start(); var_dump($message_object); $data = ob_get_contents(); ob_end_clean(); echo htmlentities($data); error_log(htmlentities($data)); echo "</pre>"; } echo $errors; $counter++; //So sleep a minute every 50 messages, or for an hour after 500 if (($counter % 50) === 0) sleep(60); if (($counter % 500) === 0) sleep(60*60); } $query = "update mail set sent_date = now() where mail_id = $mail_id"; mysql_query($query) or die("$query\n" . mysql_error()); } ?> -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php