I am doing something similar to what you are doing. Sending out a newsletter
of about 1500 every month.

I have one table that holds every people.
I also have a campaign table. Every month I create a new newsletter
campaign.  The campaign holds things like name of campaign, date sent and
location of HTML version of newsletter.

When it comes time to send out the newsletter I call my PHP script passing
it the campaign name.  The script loads the newsletters info and starts
sending.  The only sends 100 emails at a time.  I have a table that holds a
counter index, each time increasing it by 1. First 100  = 1, next 100 = 2
etc...

Also after each email is sent I insert a record into a send_tracker table,
This includes who the email went too, campaign, data send and a status
field.  If an error is found in sending the email it inserts an error
message in the status field.  Of course if it is a critical error the whole
script dies.  But if my PHP script can handle the error it inserts the
message and goes on. Example error, invalid email address.

I call my script through a cron job, it calls the script every 1/2 hours,
each call it sends the next 100 emails.  It uses the index counter table to
know were it left off.  Once the index count is great then the number of
emails to send the script does not when called, I just remove the cron the
next day when I know it is done.  Then I run a couple queries on the
send_tracker table to see if any errors happened.  If half way through the
send the email server stopped sending. Example the mail() function stops
working I know were it stopped, I fix the problem and start the sending were
it left off again.

This is just a simple description of my app, there is a lot more to it.  I
don't know if this is the best way to do it, but it works for me right now.

My two cents.
Mark.


"Kevin Stone" <[EMAIL PROTECTED]> wrote in message
00eb01c2cbb4$393fceb0$6601a8c0@kevin">news:00eb01c2cbb4$393fceb0$6601a8c0@kevin...
> ----- Original Message -----
> From: "Lowell Allen" <[EMAIL PROTECTED]>
> To: "PHP" <[EMAIL PROTECTED]>
> Sent: Monday, February 03, 2003 10:37 AM
> Subject: [PHP] tracking bulk email
>
>
> > I've added an email feature to a content management system that will
send
> > plain text email to about 1400 contact addresses. Each contact is sent a
> > separate email with the contact name and address in the "To:" header. It
> > works fine to small test lists, but hasn't been tested with a large
list.
> >
> > Although I think list posts should only pose one question, I have two:
> >
> > (1) My client is nervous about the script failing mid-list and not being
> > able to determine which contacts were sent mail. I need a way to build
> this
> > check into the content management system. I could write a flag to the
> > database every time mail() returns true, but that would mean 1400
database
> > updates! If I instead append to a variable each time through the mail()
> > loop, I'll lose the record if the script times out. Can anyone suggest a
> way
> > to record the position in a loop if a time out or failure occurs?
>
> > (2) In order to avoid the script timing out, I'm counting the number of
> > mail() attempts and calling set_time_limit(30) every 50 attempts to
> provide
> > another 30 seconds of script execution time. I'm on a commercial Linux
> host,
> > PHP 4.1.2, phpinfo.php shows the configuration command includes
> > '--enable-safe-mode', but the directive safe_mode is "Off". I'm building
a
> > test list with over 100 messages, but has anyone done something similar
to
> > prevent the script timing out when sending lots of mail?
>
> > Thanks.
> >
> > --
> > Lowell Allen
>
> In response to your first question.  File stores are something a computer
> does very very fast (might want to add some error catching to this)..
>
> $i=0
> while() {
>        count_index($i)
>        $i++;
> }
>
> function count_index ($i) {
>        $fp = fopen('count.txt', 'w');
>        fwrite($fp, $i);
>        fclose($fp);
> }
>
> In response to your second question.  Sure provided you're not outputting
> anything you can do header('Location: myscript.php'); every 25 - 30
seconds
> to relaunch the script.  Open your log file and start from the printed
> value.
>
> - Kevin
>
>



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

Reply via email to