On Thu, 18 Jul 2002, Brad Forschinger wrote:
Going from the setup at http://www.cis.hut.fi/kaip/mail/procmailrc I
decided to go one step further. I couldn't use $MATCH with lists that
have Sender: set to *-owner@ or *-admin@, so I used Perl. Any tips?
% tail -7 .procmailrc
:0h
MAILING_LIST_NAME=|~/.procmail/get_mailing_list_name.pl
:0:
* $MAILING_LIST_NAME ?? ^[a-z]+
| formail -A"X-Sorted: mailing list $MAILING_LIST_NAME" >>
list-$MAILING_LIST_NAME
% cat ~/.procmail/get_mailing_list_name.pl
#!/usr/bin/perl -wT
use strict;
while (<>) {
last if /^$/;
chomp;
if (/^Delivered-To: mailing list ([^(_at_)]*)@(.*)/ or
/^Sender: (.*)-(?:owner|admin)@(.*)/ or
/^Sender: owner-([^(_at_)]*)@(.*)/) {
my ($list_source, $list_name) = ($2,$1);
$list_source =~ tr/A-Z/a-z/; $list_source =~ s/[^a-z0-9]/_/g;
$list_name =~ tr/A-Z/a-z/; $list_name =~ s/[^a-z0-9]/_/g;
print "$list_source-$list_name\n";
last;
}
}
I do not know perl enoth but I gues that you want the left and
right sides of the "@", and with a little chutzpah i'll try to
help :)
Try to play with this little demorc:
LOGABSTRACT=all
SHELL=/bin/sh
VERBOSE=yes
DEFAULT=/dev/null
MAILING_LIST_NAME="Delivered-To: mailing list owner-mmm(_at_)xxx"
#MAILING_LIST_NAME="Sender: owner-mmm(_at_)xxx"
:0
* 1^0 MAILING_LIST_NAME ?? ^Sender: \/owner-[^(_at_)]*@.*
* 1^0 MAILING_LIST_NAME ?? ^Delivered-To: mailing list \/[^(_at_)]*@.*
{
m=$MATCH
:0
* m ?? ()\/[^(_at_)]+
{
list_name=$MATCH
}
:0 A
* m ?? ()(_dot_)*(_at_)\/.+
{
list_source=$MATCH
}
}
1> I take only two examples and hope you will understand
how to add more.
2> What is play with the demorc? Run from the command line:
formail < /dev/null | procmail ./demorc
The log will show you if you get what you want.
Change the comment to test the second MAILING_LIST_NAME case
and run again.
I wonder if it helps you.
Bye,
Udi
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail