procmail
[Top] [All Lists]

Re: How do you strip characters from the from?

2004-11-23 13:25:33
On Tue, Nov 23, 2004 at 06:19:05AM -0500, Poohba wrote:
I have, which I assume is wrong because its not working:

And what do your logs tell you?  I suggest you start using
verbose logs to troubleshoot your syntax errors and as a
way to help yourself improve your procmail skills.


BLACK=$HOME/.kills
:0:
* ^From:.*\/[A-Za-z0-9_(_dot_)+-]+(_at_)[A-Za-z0-9_(_dot_)+-]+
$MATCH =~ s/\w.*\@//;
* ? grep -i "$MATCH" $BLACK
trash

I know that is actually perl but didn't know what else to try.  What

Well, it seems silly to me to just type in perl syntax, find it doesn't
work, and then ask for help without first doing a bit of self-help with
the procmail man pages, FAQs, etc.  You've posted a number of times
in recent weeks, so you're by rights not a rank newbie with procmail.
Since you've shown that you know perl, the holes in your procmail
knowledge _ipso facto_ are not from lack of the ability to think about
code.  Time to start educating yourself a bit more about its basic
ruleset if you're going to use it with regularity . . .

Anyway, even if your parsing of MATCH were correct syntax, you
cannot assign a variable in the middle of a procmail recipe.

Btw, your first condition regex is overly restrictive to the left of the
@, and under-restrictive on the right.  (Mail addresses can have other
chars in them; domain names, however, can't technically have plus
signs or hyphens in them.)  On the third hand, new domain names are
coming with, e.g., diacriticals such as German umlauts.  Hmm.  (That
will be a mess if it catches on.)

Also, procmail is not case-sensitive for condition-matching unless you
specify that it be with the D flag.

Next, why are you capturing to the right of @ if you only then
want to throw it away?

  :0:
  * ^From:.*\/[^["'<(   ]+@
  * ? grep -qs -i "^$MATCH" $BLACK
  TRASH

Notice that I put an anchor caret in front of the $MATCH.
That's so you won't accidentally grep "oobar@" against "foobar@"
and think you have a match.

Finally, it seems like begging for trouble to me to block senders
based on the local name parts of addresses, but what do I know?

-- 
dman

____________________________________________________________
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

<Prev in Thread] Current Thread [Next in Thread>