in reply to Re: Re: sending bulk emails in a specified time
in thread sending bulk emails in a specified time

lol nah im not doing it for spam purposes :) cheers for the code, it works a treat except for one problem, im running my perl script from a browser so the browser is sitting there processing the emails for a couple of minutes before the perl script can carry on and redirect the page, how do i over come this, i want the page to redirect and have the emails sent in the background, so i can continue to use the page. i also want to try and aviod timeouts if possible, have u got any suggestions? thanks i appreciate your help :)
  • Comment on Re: sending bulk emails in a specified time

Replies are listed 'Best First'.
Re: Re: sending bulk emails in a specified time
by gellyfish (Monsignor) on Feb 04, 2002 at 12:34 UTC

    If your webserver is running an OS that supports it then you could use fork something like :

    #!/usr/bin/perl -w use CGI qw(redirect); use strict; $| = 1; if (my $pid = fork) { print redirect 'http://www.whatever.com'; } else { close STDIN; close STDOUT; # do your mail sending here }

    Closing STDIN and STDOUT is important so the server knows to close the connection to the browser

    /J\

      ok thanks heaps but im unclear about a few things, i dont quite get how the code above works, u set $pid = fork, making the if statement true, so the broswer redirects when the if statement gets executed, how will the else statement that sends the emails ever get executed? i did run this code in my script and it appears to work, however im not 100% sure the fork was created, is there little test i can do to see if the fork was created and the fork actually send the emails and not the script itself that sent the emails? thanks