RE: [PHP] PHP and email

From: Date: Wed, 23 Nov 2005 15:23:58 +0000
Subject: RE: [PHP] PHP and email
Groups: php.general 
Request: Send a blank email to php-general+get-226359@lists.php.net to get a copy of this message
> > John Nichel wrote: > > Angelo Zanetti wrote: > > > >> Hi > >> > >> I have a dedicated server in the states. > >> > >> I need to send about 8000 emails (once off). There pretty > small +- 5KB. > >> > >> > >> so I want to write a php script and run it from the > command line in > >> the background. I was thinking of sending 50 emails then > waiting 90 > >> seconds then sending again. > >> > >> Or > >> > >> the same script gets run by cron every 90 seconds and just > sends 50 > >> emails. > >> > >> What do you recommend? > > > > > > I would send them one at a time. While the script itself > could probably > > handle sending 50+ at a time, you have to think about the > mail server. > > Say you have the 8000 emails in an array.... > > > > #!/usr/local/bin/php > > <?php > > > > // Stuff to get email addresses > > // and create message > > > > foreach ( $emails as $email ) { > > mail ( $email, $subject, $message, $headers ); > > sleep ( 10 ); > > } > > > > ?> > > > > YMMV > > > Thanks to those who have replied so far, yes our main concern is the > smtp server falling over or dying. So to come back to John > Nichel's answer: > > John, have you done this personally and I assume the effects were > good?? IE everything ran smoothly? I have done it just as John has described above, though I didn't have 8000 to send. All went well, no hiccups. A couple of things I would mention is that I seem to remember reading somewhere that the sleep() function on Windows eats a lot of processor. Not an issue for me since I'm on Linux, but worth a mention. And the function John suggested above will take over 22 hours to send 8000 emails. Since you say its a one shot deal, its probably OK. JM

« previous php.general (#226359) next »