2 # fixscript will replace this line with require innshellvars.pl
4 # news to mail channel backend
8 # for each article that needs to be mailed. We invoke sm on the
9 # localhost to get the actual article and stuff
10 # it down sendmail's throat.
12 # This program expect to find a file that maps listname to listaddrs,
13 # @prefix@/etc/news2mail.cf
14 # which must contain address mapping pairs such as
16 # big-red-ants@ucsd.edu big-red-ants-digest@ucsd.edu
18 # where the first token is the name fed to us from INN, and which is
19 # also placed in the To: header of the outgoing mail. It's probably
20 # the subscriber's list submittal address so that replies go to the
21 # right place. The second token is the actual address sendmail ships
24 # In the INN newsfeeds file, you need to have a channel feed:
25 # n2m!:!*:Tc,Ac,Wn*:@prefix@/bin/news2mail
26 # and a site for each of the various mailing lists you're feeding,
28 # big-red-ants@ucsd.edu:rec.pets.redants.*:Tm:n2m!
30 # Error handling is nearly nonexistent.
32 # - Brian Kantor, UCSD Aug 1998
40 my $cfFile = $inn::pathetc . "/news2mail.cf" ;
41 my $sendmail = $inn::mta ;
42 my $sm = $inn::pathbin . "/sm" ;
46 # the syslog calls are here but don't work on my system
48 openlog('news2mail', 'pid', 'mail');
50 syslog('info', 'begin');
53 # load the list names and their mail addresses from cf file
54 # #comments and blank lines are ignored
56 unless (open CF, "< $cfFile") {
57 syslog('notice', 'CF open failed %m');
63 my ( $ln, $ma ) = split /\s+/;
69 # for each incoming line from the INN channel
76 my ($token, $lnames) = split /\s+/, $_, 2;
77 my @addrs = split /\s+/, $lnames;
79 my @good = grep { defined $maddr{$_} } @addrs;
80 my @bad = grep { !defined $maddr{$_} } @addrs;
83 syslog('notice', "unknown listname $_");
88 syslog('info', 'skipping unknown lists: ', join(' ', @bad));
90 mailto($token, $lnames, @maddr{@good});
93 syslog ("info", "end") ;
100 my $sendmail = $inn::mta ;
101 $sendmail =~ s!\s*%s!! ;
102 my @command = (split (' ', $sendmail), '-ee', '-fnews', '-odq', @a);
103 # @command[0] = '/usr/local/bin/debug';
105 syslog('info', join(' ', @command));
107 unless (open(SM, '|-', @command)) {
108 syslog('notice', join(' ', '|', @command), 'failed!');
112 my $smgr = "$sm -q $t |";
114 unless (open(SMGR, $smgr)) {
115 syslog('notice', "$smgr failed!");
123 # empty line signals end of header
125 print SM "To: $l\n\n";
130 # skip unnecessary headers
132 next if /^NNTP-Posting-Date:/i;
133 next if /^NNTP-Posting-Host:/i;
134 next if /^X-Trace:/i;
139 # convert Newsgroups header into X-Newsgroups
141 s/^Newsgroups:/X-Newsgroups:/i;