[thelist] Perl: when to close sendmail
Tony Grimes
algrimes at acs.ucalgary.ca
Mon Aug 13 14:39:28 CDT 2001
Hi,
I'm writing a Perl script that will email multiple email
subscriptions to Smartlist using sendmail. I'm planning on putting the
sendmail code in a subroutine, but I'm wondering if I should open/close
sendmail from within the subroutine. For example, here is what the code
might look like (I haven't actually written the script yet):
<CODE>
foreach $list (@lists) { # @lists and $email imported from web form
$list = "$list"."-request at my-company.com";
mail_it("$list", "$email");
}
sub mail_it {
open MAIL, "|/usr/lib/sendmail -t -i"
or die "Could not open sendmail: $!\n";
print MAIL <<END_OF_MESSAGE;
To: $_[0]
From: $_[1]
subscribe
END_OF_MESSAGE
close MAIL or die "Could not close sendmail properly: $!\n";
}
</CODE>
Will there be any problems if I open and close sendmail each time a
message is sent? Does it increase chances of a sendmail crash, or put
too much stress on the server? Is there a better way to do this? Any help
would be much appreciated.
BTW, I just typed the code on the fly, so please ignore syntax errors,
etc. I'm just trying to get across the general concept.
.tony
More information about the thelist
mailing list