|
Posted by Rasmus Lerdorf on 10/21/78 11:12
None of this makes any sense. PHP is a server-side request-based
language. If you want to put a delay in between things on a request,
call sleep(), but it is still just a single request which is going to
take a finite amount of time to run.
The correct way to send a bunch of emails is to queue them in your MTA
and have your MTA do efficient grouping and delivery of the messages.
Use the right tool for the job.
-Rasmus
Andrew wrote:
> hello,
>
> i've been searching for a 'setInterval' function in php and haven't had
> much luck.
>
>
> in actionscript (which is similar to php) you can make a function which
> calls another function at a set interval, and i was keen to do this with
> php for a mail script so that rather than sending 500 emails at once, i
> can send 10 emails every 10 seconds etc.
>
> i'm currently thinking i'll have to use flash to make the interval, but
> would rather keep it all in php.
>
> basically what i want to do is this.
>
>
> function SendMail($howManyToSend, $fromWhatIndex){
> // gets the number of email addresses ($howManyToSend)
> // from the database, starting at index $fromWhatIndex
> // then sends them
>
> if(all emails sent, no more emails in DB){
> return 'finished';
> }else{
> return 'keep them coming';
> }
> }
>
> function IntervalCalled (){
>
> // increment currentIndex
> $currentIndex = $currentIndex + 10;
>
> $howDidWeGo = SendMail(10, $currentIndex);
>
> if($howDidWeGo == "finished"){
> // FLASH CLEARINTERVAL COMMAND
> clearInterval($makeEmailsInterval);
> }
>
> }
>
> // THIS IS HOW I WOULD CALL THE INTERVAL IN FLASH
> // (for every 10 seconds)
>
> $makeEmailsInterval = setInterval(IntervalCalled, 10000);
>
>
>
>
> so is this possible with PHP by using functions? anything involving
> complicated server stuff means i may as well setup flash to call the
> interval instead of PHP
>
>
> many thanks
>
> andrew
>
[Back to original message]
|