"Alexis Birkill" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED].;
> Hi,
>
> I'm trying to track down an odd problem in a script I'm writing, the
> purpose of which is below:
>
<snippage>
>
> The PHP can be found below - I'm already resetting the set_time_limit on
> each loop execution, so as I understand it the script should happily run
> for as long as necessary.  We do not have access to configure the PHP
> installation on the server (running 4.1.2)
>
> Code follows - I hasten to add that this appears to work admirably on
> small lists.

After reviewing your code, I was wondering if there was a reason you aren't
using PHP's built-in mail() function, rather that using popen() and a series
of fputs(), which seems rather expensive, especially inside of a loop. Also,
you only need to use set_time_limit() once, outside of your loop-- pass 0 as
the parameter, which basically turns off the timeout.

Here's how I would code this:

    $counter = 0;
    set_time_limit(0);
    if ( $fp = fopen($list, 'r') ) {
        while ( $address = fgets($fp, 255) ) {
            mail( $address, $subject, "header goes here\n$body\nfoot goes
here\n", "From: Sender <[EMAIL PROTECTED]>\n" );
            $counter++;
        }
        fclose( $fp );
        print("Message successfully sent to $counter recipients from the
$list");
    }

Hope this helps.


--
Jon Abernathy - [EMAIL PROTECTED]
Alpine Internet Solutions - www.alpineinternet.com




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to