navelgazing.omphaloskeptic.net Login | Journals | Index | Printable |

AnnounceScript

#!/usr/bin/perl

# announcement.txt should be a text file formatted as an email
# Make sure it has a Subject: line and a From: line and that there's
# a blank line between the header lines and the body of the invitation
# see SampleAnnouncement
# To:, Date:, and Message-ID: lines will be generated automatically

# addresses.text should be a text file with one email address per line
# everything after a mesh (#) on a line is ignored

if ($#ARGV != 1) {
    die "usage: announce.pl announcement.txt addresses.txt\n";
}

open(ANN, $ARGV[0]);
while (<ANN>) { $mail .= $_; }
close(ANN);

if ($mail !~ /Message-ID:/i) {
    $hostname = `hostname`;
    chomp($hostname);
    $id = "<$$." . time() . "\@$hostname>";
    warn "No message-id. Using $id\n";
    $mail = "Message-ID: $id\n" . $mail;
}

open(ADD, $ARGV[1]);
while (<ADD>) {
    chomp;

    s/#.*$//;
    next unless (/\S/);

    print "mailing to $_ ...";
    open(SM, "| /usr/sbin/sendmail $_");
    print SM "To: $_\n";
    print SM $mail;
    close(SM);
    print " sent.\n";
}
close(ADD);

Public can Read by aneel at 2007-07-12 23:05:40
Linked From: InviteList