This is my batch news gateway, run every five minutes from cron. The incoming messages to the gateway are stored in a Maildir ~alias/newsdir, using a virtual domain setup that sends mail to the pseudo-domains news and news.example.com to alias-news, which is delivered by ~alias/.qmail-news-default.
My news gateway handles news from multiple hosts on my network by the simple trick of symlinking newsdir, which is exported over the LAN by NFS, into ~alias on each host, so that all the hosts store messages into the same directory. I find this easier and faster than running a copy of the gateway on each host.
The script run from cron uses maildirserial to select mail messages, and tcpclient to open an NNTP connection to the local news server, as shown in Example A-1.
Example A-1. Script called from cron to push out news
#!/bin/sh exec setlock newsdir.lock \ maildirserial -b -t 345600 newsdir alias-news- \ tcpclient localhost 119 \ /var/qmail/alias/newsgate alias-news-
The actual mail to news script is fairly long, but nearly all of it is devoted to cleaning up headers, as shown in Example A-2.
Example A-2. Mail to news gateway script
#!/usr/bin/perl # -*- perl -*- # process batched messages from maildirserial into news use Getopt::Std; use FileHandle; # options # -d debug, use tty for I/O # -s don't use date from incoming messages # to avoid complaints about stale news getopts('ds'); $linelimit = 2000; # truncate long msgs after this many lines ...