Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

My client wants automatic emails based on user input to go back to the user after a 10 minute delay. Anyone have an idea as to how to do this?

Replies are listed 'Best First'.
Re: Delayed email response
by cacharbe (Curate) on Oct 19, 2001 at 03:15 UTC
    Sure, I know exactly how I would do it. What have you tried?

    Look at cgi, MIME::Lite and sleep.

    C-.

Re: Delayed email response
by blackjudas (Pilgrim) on Oct 19, 2001 at 04:54 UTC
    You have different solutions on this matter, one is the following:
    use strict; use MIME::Lite; use CGI qw(:standard); if (param('send')) { my $email_message = 'Message'; sleep(600); send_msg(param('to'), param('message')); } sub send_msg ( my ($to, $message) = @_; my $msg = MIME::Lite->new( From =>'you@yourdomain.com', To =>"$to", Subject =>'Your 10 min delayed response', Data =>"$message" ); $msg->send(); )


    BlackJudas
      Sorry, quick question/observation.

      From my experience with Apache/modperl, won't sleeping for 10 minutes tie up the webserver child process, not to mention waiting 10 minutes to respond to the submitting browser?

      We use an external ISP for mail services and email server response times were holding up our web server processes for up to 10 seconds per email sent. This hammered our throughput.

      We therefore wrote a separate mailing program which read messages as text files from a directory and sent them. This mean't the web server wasn't waiting for responses from the email server as it only had to create the text file. The sending process ran every 10 minutes scanning the directory for mails to send.
      We effectively divorced the mail server speed from the web server giving a better response time.

      This might be overkill for your needs but perhaps it will help.