I recieve mail from my provider via News2email Gateway.
But I use UUCP soft. And so my mail (mow) in my mailbox
/var/spool/mail/alex. I wont to send all mail with string
"Newsgroups:" to my local news server (INND)
My /home/alex/.procmailrc file:
# Begin------------------------------------------------------
SHELL=/bin/bash
PATH= /usr:/usr/bin:/usr/sbin:/usr/local/bin
SENDMAIL = /usr/sbin/sendmail
VERBOSE = ON
LOGFILE = /home/alex/procmail.log
:0 c :
* ^Newsgroups:
| /usr/bin/mail2news
# End--------------------------------------------------------
And as you see I call mail2news:
# Begin-------------------------------------------------------
#!/usr/bin/perl
($program = $0) =~ s%.*/%%;
#( $version ) = $] =~ /(\d+\.\d+).*\nPatch level/;
#die "$program: requires at least version 3 of perl\n"
# if $version < 3;
# $inews = "/usr/bin/inews";
# $iopts = "-h -o \"mail2news gateway\"";
$inews = "/usr/local/news/bin/rnews";
$iopts = "";
$postinghost = "news.dc.ukrtel.net";
if ($#ARGV < 0) {
# $newsgroup = "test";
# we'll expect the newsgroup line in the body
} elsif ($#ARGV == 0) {
$newsgroup = $ARGV[0];
} else {
die "usage: $program [newsgroup]\n";
}
# in case inews dumps core or something crazy
$SIG{'PIPE'} = "plumber";
sub plumber { die "$program: \"$inews\" died prematurely!\n"; }
open (INEWS, "| $inews $iopts") ||
die "$program: can't run $inews\n";
# header munging loop
while (<STDIN>) {
last if /^$/;
# transform real from: line back to icky style
s/^From:\s+(.*) <(.*)>/From: $2 ($1)/;
s/Message-Id/Message-ID/;
# transform from_ line to path header; also works locally
s/^From\s+(\S+)@(\S+).*/Path: $2!$1/
|| s/^From\s+(\S+)[^(_at_)]*$/Path: $1\n/;
print INEWS
# if
/^(Date|From|Subject|Path|Newsgroups|Organization|Message-ID):/i;
if /^(Date|From|Subject|Path|Newsgroups|Message-ID):/i;
$saw_subject |= ( $+ eq 'Subject' );
$saw_msgid |= ( $+ eq 'Message-ID' );
$saw_newsgroup |= ( $+ eq 'Newsgroups' );
}
warn "$program: didn't expect newsgroup in both headers and ARGV\n"
if $newsgroup && $saw_newsgroup;
die "$program: didn't get newsgroup from either headers or ARGV\n"
unless $newsgroup || $saw_newsgroup;
$approved = $newsgroup;
$approved =~ s/\./'-'/eg;
($sec,$min,$hour,$mday,$mon,$year)=localtime(time);
$madeupid =
"\<$year$mon$mday(_dot_)$hour$min$sec(_dot_)$$\(_at_)kepler(_dot_)hedland(_dot_)edu(_dot_)au\>";
printf INEWS "Newsgroups: %s\n", $newsgroup if $newsgroup;
printf INEWS "Approved: %s\(_at_)kepler(_dot_)hedland(_dot_)edu(_dot_)au\n",
$approved;
print INEWS "Subject: Untitled\n" unless $saw_subject;
printf INEWS "Message-ID: %s\n", $madeupid unless $saw_msgid;
printf INEWS "NNTP-Posting-Host: %s\n", $postinghost;
print INEWS "Organisation: (mail2news gateway)\n";
print INEWS "\n";
print INEWS while <STDIN>; # gobble rest of message
close INEWS;
exit $?;
# End----------------------------------------------------------
So erroo is:
procmail: Match on "^Newsgroups:"
procmail: Couldn't determine implicit lockfile from "/usr/bin/mail2news"
procmail: Locking ".lock"
procmail: Executing "/usr/bin/mail2news"
mail2news: "/usr/local/news/bin/rnews" died prematurely!
mail2news: "/usr/local/news/bin/rnews" died prematurely!
procmail: [7844] Mon Apr 19 21:13:17 1999
procmail: Program failure (29) of "/usr/bin/mail2news"
procmail: Assigning "LASTFOLDER=/usr/bin/mail2news"
procmail: Unlocking ".lock"
procmail: Locking "/var/spool/mail/alex.lock"
procmail: Assigning "LASTFOLDER=/var/spool/mail/alex"
procmail: Opening "/var/spool/mail/alex"
procmail: Acquiring kernel-lock
procmail: Unlocking "/var/spool/mail/alex.lock"
From dontel!L-usenet(_at_)news(_dot_)dc(_dot_)ukrtel(_dot_)net Mon Apr 19
21:13:16 1999
Subject: [NEWS] Re: BUY ME A PONY !!!!!!
Folder: /var/spool/mail/alex
1408
procmail: Notified comsat: "alex(_at_)517:/var/spool/mail/alex"
---------------------------------------------------------------------
What's wrong? This scrip wiil work, at all?
P.S. All pathes is correct,and sorry about my english :)