| [reply] |
To elaborate on Randall's response, what you should consider doing is something along the lines of:
- Present the fill-in form.
- When processing the "submit" button, do any data-verification or sanity-checking that you feel is needed.
- Fork a child process to take care of the mailing itself. Whether you choose to do the forking in a true "clean" way is up to you, and not important here.
- The original process then displays a "Thank you" page, telling the user that their data is being processed and they'll receive mail at a future point. That part is now done. It will do nothing else until called again by another form-submit.
- The second process (the child) handles the mail task, whatever that entails.
Relevant part here is that the CGI application should not be doing silly things like "sleep" when there is a use on the other end of the wire waiting.
However, I must ask this: what point is there in waiting some period of time before sending the e-mail? All invocations of this script will be waiting as well. You will still have the problem of a flood of requests flooding the mail server, just with an n-second delay. If you are that concerned about about potential mail flooding, then you have a different sort of application to consider.
--rjray
| [reply] |
ok thanks heaps guys, thanks rjray you cleared alot of stuff up that i wasnt sure about. your right about the waiting period, and my broswer was waiting minutes before the perl script was finished sending the emails (very inneffcient!) i am new to this mass mailing stuff and im learning as im going. someone else on another forum suggested a put a delay of a second between sending each email, it sounded like the right thing to do but it just doesnt work for what im doing (as im making the request from the browser).
I did look at a number of professional programs like "subscribeme" that do mass mailings and none of them mentioned anything about forking a process, so i had no idea i would need to do this, it does make sense and it does solve my problem so thanks heaps you have really saved my butt! excellent learning excercise :)
| [reply] |
Hi,
Are you system administrator in the machine which have the script?
Your question "is not perl related" I think. You can configure the script timeout in webserver's configuration file.
As merlyn said, you are trying to do tasks that isn't supposed to do by a CGI.
Use better a non CGI script to do this jobs.
Hopes
$_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s,
$_^=q,$\^-]!,,print
| [reply] [d/l] |
One simple technique for keeping the browser happy while a long-running CGI is cranking away is to unbuffer STDOUT, then periodically print
<!--ping-->
It's a kludge, but it works.
| [reply] [d/l] |
I might suggest Mail::Bulkmail. You're probably better off queueing the request via CGI and performing the actual sending of mail in a separate job, either forked from your CGI or spawned independently (e.g. a cron job set by the CGI or checking for the presence of a flag set by your CGI). | [reply] |