Simple mail from list
I've written a very simple message board for family and friends that resides in a protected directory. What I need to do is a quick mail out every time a message is posted - to all the people on a list.
I looked around, but couldn't find a nice simple mail list thing in Perl. They're all large programs like newsletters or massive bulk mail things. I don't really need all that for what I'm doing.
I doubt there will be more than a dozen people on the list, ever.
File - mail.txt
Dan|dan@dada.com|
Sam|sam@sasa.net|
Bob|bob@bobo.org|
Joe|joe@jojo.com|
This is as far as I've got. The problem is, that the poster gets an email too and they shouldn't. Have no idea how to correct that.
## Variables to use
$mbttle = "Message Board";
$mbsubj = "New Message Posted";
$viewit = "http://thedomain.net";
$from = "me\@mine.net";
$userdb = "mail.txt";
$tester = "test.txt"; # temporary for tests
$poster = "Dan"; ## temporary for tests
## Mail message
@msg = "
A new message as been posted by:$poster
View: $viewit\
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-";
open (UDB,"$userdb") or die "can't open $userdb: $!";
@ud=<UDB>; close (UDB);
foreach $usr (@ud) {
($nm,$em)=split(/\|/,$usr);
print qq ~$nm, $em<br>~; ## just to see the list
## write to test file like it is sendmail
### -- Doesn't do it right. Posters name should not be there
open (TSF,">>$tester") or die "can't open $tester: $!"; @tf=<TSF>;
print TSF "To: $em\n";
print TSF "From: $from\n";
print TSF "Subject: $mbsubj\n";
print TSF "@msg\n";
close (TSF);
} # end foreach
Can anyone help on this please?
Thanks.