Re: Best way to mass mail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:50 AM 9/12/2005, Ryan A wrote:
Hi,
My client has a dating site and now he wants to mail all his members,
he does not want to use any of the already installed mailing lists but wants
us to make one
for him, he's on a dedicated server.

Presently he does not have too many members, just a few thousand (around 3k
i guess),
I remember reading sometime back on the list that using the mail() may not
be the best
option...not sure if thats still true.

The thing that bothers me the most is if the program times out..., how do I
start again from
the ones that have not been sent?

eg:
(10 members)
mail gets sent to first 4 members then times out
we re-click on the send button and it starts again from one...again times
out
(this happens 5 times)

that means members 1-4 will get the same email 5 times

Doing this the hard way would be to connect to the db after each successful
mail and "mark"
each member with todays date or something...but I would like to avoid so
many calls to the
DB if possible...esp if the site grows.

Ideas/suggestions?

Thanks in advance,
Ryan


We send to 1,000 subscribers each night, here's the guts of the code. There's one call to fetch the names and email addresses from the database.

                        while( $row = mysql_fetch_array( $result ) )
                        {
                                $first_name = $row[ first_name ];
                                $last_name      = $row[ last_name ];
                                $email          = $row[ email ];

                                /* recipient */
                                $recipient = $email;

                                /* send it */
$lMailedOK = mail($recipient, $subject, $message, $headers);
                                if ($lMailedOK != 0 )
                                {
                                        $lMailedOK = "OK";
                                }else{
                                        $lMailedOK="<b>FAILED</b>";
                                }
                                echo $recipient . " - " . $lMailedOK ."<br>";
                                // give ourselves more time
                                set_time_limit( 20 );
                        } //$row = mysql_fetch_array( $result )

$message is built higher up in the process - I keep resetting the time out - set_time_limit(20).
After each message is sent, $lMailedOK and the names are echoed to the browser.

When the process completes, we know who it went to and if the call to mail() succeeded.

Hope this is helpful - Miles Thompson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux