I know Im going to get flamed for this becuase Im not using a module, but
its quick and it works, plus that its quicker becuase it doesnt even open
up a pipe..It uses a simple socket connection to a sendmail server (just one)
#!/usr/bin/perl
use strict;
use Socket;
my @users=('email1@server.com', 'email2@server.com', 'email3@server.co
+m');
my $mailhost="localhost";
my $myemail="mark\@cidera.com"; # Your email address
# this is just the subject and body of the message
# you can get this information from anywhere I just
# put it in here for the sake of example
my $subject= "hi";
my $data = "hi hi hi hi there";
my $userz;
socket(MAIL,PF_INET,SOCK_STREAM,getprotobyname('tcp'));
connect(MAIL,sockaddr_in(25,inet_aton($mailhost)));
select(MAIL);
$|=1;
select('stdout');
print MAIL "HELO blah.com\n";
foreach $userz (<@users>) {
print MAIL "MAIL FROM: $myemail\n";
print MAIL "RCPT TO: $userz\n";
print MAIL "DATA\n";
print MAIL "Subject: $subject\n";
print MAIL "$data\n";
print MAIL ".\n";
}
print MAIL "quit\n";
close(MAIL);
This works becuase it doesnt quit the sendmail connection till after all the emails have been sent to each person in your @users array seperatly.
I know this isnt EXACTLY what you were looking for, but its just another way to do this.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.