Dallman Ross wrote:
On Fri, Mar 07, 2008 at 05:30:42PM +0000, Paul Gardiner wrote:
For mail that comes into my secondary MX, I use the following to
sort mail to valid addresses from that to invalid ones:
:0
* ^To.*glidos\.net
{
VALID=`cat /etc/postfix/virtual | sed -n -e
's/^\((_dot_)*(_at_)glidos(_dot_)net\).*$/\1/p' | sed -e 's/ /|/g'`
:0:
* ? formail -x To: -c | egrep -i ${VALID}
.Glidos.Glidos/
:0:
.Stuff.Invalid/
}
Used to work fine, but as the number of addresses stored in "virtual"
has increased, it fails to match some of the later ones. It's as
thought there's a line length limit. I tried splitting the content
of "VALID" into two and checking each part separately. That didn't
help, so maybe its nothing to do with line length limits.
I don't know, but your sed statements aren't very efficient. You
shouldn't need to pipe sed through sed.
Try something like this there:
VIRTUAL = /etc/postfix/virtual
VALID = `fmt -1 "$VIRTUAL" | sed -n '/@glidos[.]net/{s/[^a-zA-Z]*$//;
s/$/|\\/p;}'`
VALID = "(${VALID}dummy)"
Another problem is that you will get false positives on addresses
that are subsets of others. Example: valid address
goldman(_at_)glidos(_dot_)net;
spam comes in to dman(_at_)glidos(_dot_)net(_dot_) Use the -w option to
egrep.
Thanks, tips on sed are always useful, but I'm not too bothered about
effeciency or the odd false positive. It's the 50% false negatives that
I want to fix.
What I posted before was slightly wrong: should have been
VALID=`cat /etc/postfix/virtual | sed -n -e
's/^\((_dot_)*(_at_)glidos(_dot_)net\).*$/\1/p' | xargs | sed -e 's/ /|/g'`
even less efficient, but at least correct this time.
It works outside of procmail, but not within procmail: the addresses
past a certain point in virtual don't get matched. That's something
odd about procmail. I'd have thought that something worth investigating.
P.
____________________________________________________________
procmail mailing list Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail