[thelist] Perl: when to close sendmail
Chuck Sumpter
frodo_tx at yahoo.com
Mon Aug 13 16:10:14 CDT 2001
-- Tony Grimes <algrimes at acs.ucalgary.ca> wrote:
> 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 went here, trimmed to please list overlord
> 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.
Tony,
Here is a snipet of code that I had in a perl script to send e-mails out to
users asking for some action on their part. I was processing an extract from
a DB and deciding who to send emails' to. I never did an open/close, just
populated some vars with the "stuff" to send and then did this within the while
loop that ground through the file...
<CODE>
%mail = ( To => $user_addr,
From => $admin_addr,
Subject => $subject,
Message => "@msg_to_user"
);
sendmail(%mail) or die $Mail::Sendmail::error;
++$email_sent;
</CODE>
I generated 5k plus messages with no problems....however it is a big server on
an intranet. Maybe someone else has a better idea. That's the good thing
about Perl, 1000 ways to do most things :)
HTH,
Chuck
oops, almost forgot "use Mail::Sendmail;" up front... :\
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
More information about the thelist
mailing list