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

It seems any SMTP method I choose has an undesierable delay. I've tried sendmail, Net::SMTP, and MIME::Lite. Each seems to get bogged down if it hasn't been run in the last 15 minutes or so. I know it's a problem with my mail server, but I'm looking to solve it with perl. My problem is that while users are waiting for the email to kick in from my site, they either leave or hit stop. I've looked at fork() some, but I'm not sure if it's what I need. I believe, that if I start a new process to perform email functions, the user will be quickly redirected and the other process can finish normally without risk of user-interruption. Can anyone offer any tips or methods to accomplish this?

Replies are listed 'Best First'.
Re: Spawning an Independant Process
by tinman (Curate) on Apr 14, 2001 at 10:13 UTC

    I don't know if you can do anything with conventional modules per se... working primarily on Windows, I don't know fork either... but I had a similar problem and in the hope of it helping you get an idea, I'll pass it on...

    Write everything you need to send the mail to offline storage... For example, to a file(s), or to a database. Then, have a script running in tbe background that periodically wakes up, checks for new messages, sends the mail off, and goes back to sleep again...

    This way, your users need to wait until their message is recorded in permanent storage, and then they can be away to other places...

    When I did this, I gained other advantages, such as better auditing, failsafe response to the mail server being down for maintenance.. Obviously this works only if some delay between the user clicking "send mail", and actually sending the mail to the SMTP server is tolerable... YMMV
    HTH

Re: Spawning an Independant Process
by merlyn (Sage) on Apr 14, 2001 at 17:40 UTC