Thread: email question

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    54
    Rep Power
    15
    The requirement is to be able to send a personalized email to each of several thousand recipients, in either HTML or plain text format.

    Currently, the list of addresses is generated by querying a MySQL table using PHP. This list is presented (one address per line) in a textarea form field on a "preview" page and can be modified before actually sending out the emails.

    When the preview page is submitted, a confirmation page comes up, and the emails must actually be sent.

    Part of the difficulty I'm having is this: while I can use system("./email.cgi&"); to launch a call to the email.cgi script so that it runs in the background while the confirmation page sent.cgi is displayed, the browser doesn't indicate that the page is "completed" until email.cgi finishes. (E.g., in Explorer, the "processing" icon in the upper right continues to be in motion during this time.)

    Another part of the difficulty is that of passing the long list of email addresses to the email.cgi script. When I'm just testing, I use a loop to send a certain quantity of emails to an address used for test purposes; however, in reality, I need to pass the actual list to the script. I'm guessing that a list of nearly 10,000 email addresses is too long to pass in an argument list. (I know it would be too long for the environment QUERY_STRING.) Is there a preferred way of conveying a large quantity of data in such a situation? Do I have to save it to a file first, or is there a more direct way?


    From a slightly different angle:

    Something else I have tried is having the preview page send the form data directly to email.cgi and having email.cgi launch the confirmation page using a system() call. Since the preview page calls the cgi script using the POST method, the amount of data being passed isn't a problem. The problem is that, while the confirmation page does get displayed, the browser doesn't indicate that it's finished loading until the emails have been processed. This might be tolerable for a few emails, but I don't think it's going to work for a large quantity.


    Thanks for any suggestions,

    Rick
  2. #2
  3. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    14
    Here is a simplified example of using the fork() function as mentioned in the MySQL forum.

    Code:
    $pid = fork();
    print "Content-type: text/html nn fork failed: $!" unless defined $pid;
    if ($pid) {
        # parent process
        # Display confirmation
    	exit;
    }
    else 
    {
         # child process
         close (STDOUT);
    # Do the mass emailing here
    
     }
    Now when the parent process is executed, displaying the confirmation page, the child process is then spawned and executed. So the mass mailing is done in the "background" without delaying the parent process.

    Mickalo


    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    54
    Rep Power
    15
    Thanks for the input. I've never done anything with a fork before, and the code looks a little strange to me: the condition looks as though _either_ the confirmation will be displayed _or_ the emails will be sent. I'll try it out and see how it works.

    --Rick

IMN logo majestic logo threadwatch logo seochat tools logo