You might want to check into Mail::Bulkmail.
It has a slew of nice features, is fast, etc. I have code that uses Mail::Bulkmail that I can share if you want to give it a try.
Executing sendmail directly can be risky and error prone.
/\/\averick
perl -l -e "eval pack('h*','072796e6470272f2c5f2c5166756279636b672');"
| [reply] |
First off, i agree with /\/\averick that calling sendmail directly is risky, but if you must do such things (e.g. prod machine and modules cannot be installed with out internal QA :-( ), sendmail will take multiple addresses (untested code ahead):
my $local_addr = 'some@addr.com';
my @addrs = qw(mzsanford@cpan.org foo@perl.com joe@cool.com);
my $mail_string = join(',',@addrs);
open(MAIL,"| /usr/lib/sendmail -t") || die "fork() : $!\n";
print MAIL "From: $local_addr\n";
print MAIL "To: $local_addr\n";
print MAIL "Bcc: $mail_string\n\n";
print MAIL "Subject: hello\n";
print MAIL "foo, bar, and the like.\n";
print MAIL "\n.\n";
close(MAIL) || die "close() : $!\n";
... but i am not sure, and my unix box is down at the moment so i can't test. Also, they will get a mail from you, to you, and BCC'd to them ... common spammer stuff ... i even have a filter for it.
can't sleep clawns will eat me
-- MZSanford
| [reply] [d/l] |
| [reply] [d/l] |
There's no reason to fork in this situation when this is something that can be done easily using the SMTP protocol. Forking introduces a WHOLE mess of unnecessary problems into a simple script that could potentially kill the server ie, infinite loops. Also, forking without knowing how to clean up your children is a bad idea. AND in the event the forking loop spins off into infinity and a successful connection is made to a mail server, think of the load that'll put on the mail server unnecessarily (it could potentially use up all available file descriptors and render the mail server unreachable until the connections close).
bottom line, that is WAY too complicated, but if you're still interested I wrote up a node on forking that might be useful. I took time to read several different books and various web pages online for possible problems that I could encounter.
K.I.S.S.
-brad..
| [reply] |
| [reply] |
NAME
sendmail - an electronic mail transport agent
SYNOPSIS
sendmail [flags] [address ...]
So, you just add extra addresses at the end of the command line when calling sendmail.
Although this has nothing to do with Perl, really. | [reply] [d/l] |
You could also communicate with the MTA on the protocol level, which would be independant of where sendmail is, whether or not you're using qmail or whatever smtp agent.
cleen
wrote a good node on this a while back. I currently use that in all the scripts and programs I write to send email to a list of users. Its portable accross many different UN*X's and doesn't rely on that local machine running an MTA as I can specify the mail host to connect to.
You might also be interested in the Net::SMTP, Net::POP3 which do effectively the same thing in a module.
-brad..
'reinvent the wheel and make it bigger, better, and with metal spikes, yeah, we can never have enough metal spikes' | [reply] |