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

A client has asked us to set up a personalised opt-in mailing system on a remotely-hosted web server. We are confident there are no spam issues here, however I am concerned about the technical side.

1. The only way I know to generate personalised emails from Perl is to launch a separate copy of SendMail for each mail. The last thing I want to do is bring down the server by launching 1000+ copies simultaneously. Is there a way to achieve our objective that avoids this risk?

2. Am I right in thinking that once a Perl script is launched from a web client, the client must stay connected for the script to continue? I am concerned about the usability of a system that requires someone to wait at a computer screen until a possibly lengthy process is complete. This would be especially so if the solution to Q1 is to intersperse sleep commands between small batches of emails. Any ideas?

I did a search of the archives before posting this question and ended up downloading Mail::Bulkmail. I think maybe it is the answer, but I couldn't understand whether, in MailMerge mode, it still suffers from the same problem or not.

Replies are listed 'Best First'.
Re: Personalized emails with SendMail
by davorg (Chancellor) on Oct 08, 2001 at 14:44 UTC

    You might like to look into the "-odq" option for sendmail. This queues the email for delivery later and therefore stops your script from hanging whilst thousands of emails are send.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you don't talk about Perl club."

      That looks like it would solve both problems: neither keeping the user waiting nor flooding the server with forked processes. Have I understood correctly?

      (I love this place! Where else on the planet can one ask such esoteric questions and get answers that are not only instant but right!?!?! Thank you.)
Re: Personalized emails with SendMail
by tachyon (Chancellor) on Oct 08, 2001 at 15:27 UTC

    To expand on davorgs accurate '-odq' suggestion here is a bit of code cut out of a script:

    $mail_prog = '/usr/sbin/sendmail'; # to enable mail queueing for sendmail set this to '-odq' (set to '' f +or no queue) # *warning* -odq option needs to be configured or messages will never +be delivered! my $odq = '-odq'; open ('MAIL', "|$mail_prog -t -i $odq") or DieNice("Can't open mail pr +ogram '$mail_prog': $!\n"); print MAIL $message; close MAIL;

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Personalized emails with SendMail
by jj808 (Hermit) on Oct 08, 2001 at 14:50 UTC
Re: Personalized emails with SendMail
by ronzomckelvey (Acolyte) on Oct 24, 2001 at 08:46 UTC
    Hi-
    Why not take your messages and put them in a queue, flat file or mysql db, then have one or a few background jobs that doing nothing but loop, process mail, sleep to do all the sending.

    In your queue file you would know what personalised setting to use and etc.

    I do the same thing, kinda, I take interface files from the as/400, make either pdf's or excel spreadsheets, then email them to vendors and such.

    I use Mail::Sender and not have to rely on sendmail.

    ronzo