Large MAPS update
[clearscm.git] / maps / bin / checkaddress
index 19a0df5..97da899 100755 (executable)
@@ -2,7 +2,7 @@
 ################################################################################
 #
 # File:         $RCSfile: checkaddress,v $
-# Revision:    $Revision: 1.1 $
+# Revision:     $Revision: 1.1 $
 # Description: Check an email address
 # Author:       Andrew@DeFaria.com
 # Created:      Mon Jan 16 20:25:32 PST 2006
@@ -17,12 +17,12 @@ use warnings;
 
 use FindBin;
 
-use lib $FindBin::Bin, '/opt/clearscm/lib';
+use lib "$FindBin::Bin/../lib", '/opt/clearscm/lib';
 
 use MAPS;
 use Display;
 
-error ("Must specify an email address to check", 1) 
+error("Must specify an email address to check", 1) 
   if !$ARGV[0] or $ARGV[0] eq "";
 
 foreach (@ARGV) {
@@ -41,27 +41,35 @@ foreach (@ARGV) {
   } # unless
 
   if ($domain eq "defaria.com" and $user ne $username) {
-    display "Nulllist - $sender is from this domain but is not from $username";
+    display"Nulllist - $sender is from this domain but is not from $username";
     next;
   } # if
 
-  ($status, $rule) = OnNulllist $sender;
-
-  if ($status) {
-    display "Sender $sender would be nulllist'ed\n$rule";
+  # Algorithm change: We now first check to see if the sender is not found
+  # in the message and skip it if so. Then we handle if we are the sender
+  # and that the from address is formatted properly. Spammers often use 
+  # the senders email address (i.e. andrew@defaria.com) as their from address
+  # so we check "Andrew DeFaria <Andrew@DeFaria.com>", which they have never
+  # forged. This catches a lot of spam actually.
+  #
+  # Next we check to see if the sender is on our whitelist. If so then we let
+  # them in. This allows us to say whitelist josephrosenberg@hotmail.com while
+  # still nulllisting all of the other hotmail.com spammers.
+  #
+  # Next we process blacklisted people as they are also of high priority.
+  #
+  # Then we process nulllist people.
+  #
+  # Finally, we handle return processing
+  
+  # Check whitelist
+  if (OnWhitelist($sender, $username, 0)) {
+    display "Sender $sender would be whitelisted";
+  } elsif (OnBlacklist($sender, 0)) {
+    display "Sender $sender would be be blacklisted";
+  } elsif (OnNulllist($sender, 0)) {
+    display "Sender $sender would be nulllisted"
   } else {
-    ($status, $rule) = OnBlacklist $sender;
-
-    if ($status) {
-      display "Sender $sender would be blacklist'ed\n$rule";
-    } else {
-      ($status, $rule) = OnWhitelist $sender;
-
-      if ($status) {
-       display "Sender $sender would be whitelist'ed\n$rule";
-      } else {
-       display "Sender $sender would be returned";
-      } # if
-    } # if
-  } # if
+    display "Sender $sender would be returned"
+  } # if 
 } # foreach