procmail
[Top] [All Lists]

Re: How do you strip characters from the from?

2004-11-23 10:55:57
Poohba wrote:

<> I have, which I assume is wrong because its not working:
<> 
<> 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
<> that should do is strip from the first character to and including the
<> '@' from the var and then match it against the domain names in
<> $HOME/.kills but of course it isn't working

Yep; procmail is not perl. <g> Why not simply match against the domain
instead of grabbing the entire From: ...?

  :0 :
  * ^From:(_dot_)*(_at_)\/[a-z0-9_.+-]+
  * ? grep -i "$MATCH" $BLACK
  trash

Some people use formail(1) to grab a clean address, which makes it
easier to be sure you aren't getting garbage in your grep:

  :0 h
  FROM=|formail -IReply-To: -rtzxTo:

  :0 :
  * FROM ?? @\/.*
  * ? grep -i "$MATCH" $BLACK
  trash

Also, fgrep may be faster than grep because it isn't going to look for
regex patterns in the expression. (fgrep is fixed strings only)

R
-- 
R A Lichtensteiger              rali(_at_)tifosi(_dot_)com

  "Yes, of course, sometimes you'll be sitting in McDonald's and your
   girlfriend will say, 'You just deliberately dropped that napkin so
   you could look up the skirt of the woman over there, didn't you?'
   - everyone's had that conversation and it's perfectly healthy. There'll
   be some loud, German invective, a degree of storming out, perhaps
   mayonnaise may get thrown at some point - we've all been there."

____________________________________________________________
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>