procmail
[Top] [All Lists]

Re: matching syntax?

1997-10-07 05:29:01
Tomas Karlsson writes on 6 October 1997 at 18:17:47
How would I go about to check if the To field equals the From 
field (same email addresses)?

From my spamcheck recipes (which is derived from posts here)

-----
# Like procmail's ^TO, but for From: and CC: lines
# The extra outer layer of parentheses are so that one can use forms like
# ${FROM}* or ${FROM}+ or ${FROM}?.
CC=${CC:-"(^((Original-)?(Resent-)?(Cc|Bcc)):(.*[^a-zA-Z])?)"}
FROM=${FROM:-"(^((X-(Envelope-)?)?(Apparently-|Resent-)*(From|Reply-To|Sender):\
(.*[^-a-z0-9_])?|From ([^       ]*[-_(_at_)!(_dot_)])?))"}

SENDER=${SENDER:-`formail -rtzx To:`}
FROM_ADDRESS=${FROM_ADDRESS:-`formail -IReply-To: -rtzx To:`}

# Check if From: = To:
# We exclude anything with a Resent- header to avoid problems with
# lists that change the Reply-To: to point back to the list.
# Many people CC: themselves...
:0
* $^TO\/($SENDER|$FROM_ADDRESS)\>
* $!${CC}($SENDER|$FROM_ADDRESS)\>
* !^Resent-
{
  spamcheck_contribution=${SPAMCHECK_FROMISTO_SCORE:-$SPAMCHECK_70}
  spamcheck_reason="FROMISTO - To: $MATCH matches From:/Reply-To:"
  spamcheck_rcpath=$_
  INCLUDERC=$SPAMCHECK_RCDIR/reason.rc
}

# and From: = Reply-To:
# I've generated some messages like this myself :-), thus the added
# check against ^FROM_DAEMON
:0
* !^FROM_DAEMON
* $^(Reply|Errors)-To:(.*[^-a-z0-9_])?$FROM_ADDRESS\>
{
  # A lot of people (or MUAs) needless add a Reply-To: when the From:
  # is perfectly correct.  Maybe because that's easier than
  # configuring sendmail.cf to ensure From: is right...
  spamcheck_contribution=${SPAMCHECK_FROMISREPLYTO_SCORE:-$SPAMCHECK_10}
  spamcheck_reason="FROMISREPLYTO - From: $FROM_ADDRESS matches 
Reply-To:/Errors-To:"
  spamcheck_rcpath=$_
  INCLUDERC=$SPAMCHECK_RCDIR/reason.rc
}

# mail from real sources tends to have a name in the From: header:
#   From: "J. Daniel Smith" <DanS(_at_)bristol(_dot_)com>
#   From: DanS(_at_)bristol(_dot_)com (J. Daniel Smith)
# while SPAM is more likely just to contain an email address
:0
* !^FROM_DAEMON
* $^From:[      ]*<?$SENDER>?[  ]*$
{
  spamcheck_contribution=${SPAMCHECK_FROMNONAME:-$SPAMCHECK_20}
  spamcheck_reason="FROMNONAME - No name in From: header"
  spamcheck_rcpath=$_
  INCLUDERC=$SPAMCHECK_RCDIR/reason.rc
}
-----

You can FTP the whole shebang from
   ftp://ftp.bristol.nl/pub/users/DanS/spamcheck

   Dan
------------------- message is author's opinion only ------------------
J. Daniel Smith <DanS(_at_)bristol(_dot_)com>        
http://www.bristol.com/~DanS
Bristol Technology B.V.                   +31 33 450 50 50, ...51 (FAX)
Amersfoort, The Netherlands               {info,jobs}(_at_)bristol(_dot_)com

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