2 ################################################################################
4 # File: $RCSfile: checkaddress,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Check an email address
7 # Author: Andrew@DeFaria.com
8 # Created: Mon Jan 16 20:25:32 PST 2006
9 # Modified: $Date: 2013/06/12 14:05:47 $
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
20 use lib "$FindBin::Bin/../lib";
21 use lib "$FindBin::Bin/../../lib";
26 error("Must specify an email address to check", 1)
27 if !$ARGV[0] or $ARGV[0] eq "";
34 my $username = lc $ENV{USER};
36 my ($user, $domain) = $sender =~ /(.+)\@(.+)/;
38 unless ($user and $domain) {
39 error "Illegal email address $sender";
44 if ($domain eq "defaria.com" and $user ne $username) {
45 display"Nulllist - $sender is from this domain but is not from $username";
49 # Algorithm change: We now first check to see if the sender is not found
50 # in the message and skip it if so. Then we handle if we are the sender
51 # and that the from address is formatted properly. Spammers often use
52 # the senders email address (i.e. andrew@defaria.com) as their from address
53 # so we check "Andrew DeFaria <Andrew@DeFaria.com>", which they have never
54 # forged. This catches a lot of spam actually.
56 # Next we check to see if the sender is on our whitelist. If so then we let
57 # them in. This allows us to say whitelist josephrosenberg@hotmail.com while
58 # still nulllisting all of the other hotmail.com spammers.
60 # Next we process blacklisted people as they are also of high priority.
62 # Then we process nulllist people.
64 # Finally, we handle return processing
66 # Check which list the sender is on. Note that these function calls return a
67 # list of scalars. But if we want to check to see that the first returned
68 # item is in the list we need to use a syntax of () = func(). If instead we
69 # just use if (func()) and func returns a list, then we will not see the first
70 # scalar returned as a boolen. Using () = func() does this for us.
71 if (() = OnWhitelist($sender, $username, 0)) {
72 display "Sender $sender would be whitelisted";
73 } elsif (() = OnBlacklist($sender, 0)) {
74 display "Sender $sender would be be blacklisted";
75 } elsif (() = OnNulllist($sender, 0)) {
76 display "Sender $sender would be nulllisted"
78 display "Sender $sender would be returned"