You are here: Re: [PHP] PHP and email « PHP « IT news, forums, messages
Re: [PHP] PHP and email

Posted by John Nichel on 11/23/05 17:43

Angelo Zanetti wrote:
>
>
> 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 use some code just like that at least once a month to send out a
newsletter for a site I run, and it works fine. I'm only sending out
appx 1400 emails though, so I can afford to let it sleep for a longer
period of time. You can probably go lower on the sleep time, but it all
depends on your setup.

A better solution, if you have access to it and your mail server
supports it, is to just inject the whole thing...that way you're not
making a SMTP connection each time.

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnichel@dotcomholdingsofbuffalo.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация