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", '/opt/clearscm/lib';
25 error("Must specify an email address to check", 1)
26 if !$ARGV[0] or $ARGV[0] eq "";
33 my $username = lc $ENV{USER};
35 my ($user, $domain) = $sender =~ /(.+)\@(.+)/;
37 unless ($user and $domain) {
38 error "Illegal email address $sender";
43 if ($domain eq "defaria.com" and $user ne $username) {
44 display"Nulllist - $sender is from this domain but is not from $username";
48 # Algorithm change: We now first check to see if the sender is not found
49 # in the message and skip it if so. Then we handle if we are the sender
50 # and that the from address is formatted properly. Spammers often use
51 # the senders email address (i.e. andrew@defaria.com) as their from address
52 # so we check "Andrew DeFaria <Andrew@DeFaria.com>", which they have never
53 # forged. This catches a lot of spam actually.
55 # Next we check to see if the sender is on our whitelist. If so then we let
56 # them in. This allows us to say whitelist josephrosenberg@hotmail.com while
57 # still nulllisting all of the other hotmail.com spammers.
59 # Next we process blacklisted people as they are also of high priority.
61 # Then we process nulllist people.
63 # Finally, we handle return processing
65 # Check which list the sender is on. Note that these function calls return a
66 # list of scalars. But if we want to check to see that the first returned
67 # item is in the list we need to use a syntax of () = func(). If instead we
68 # just use if (func()) and func returns a list, then we will not see the first
69 # scalar returned as a boolen. Using () = func() does this for us.
70 if (() = OnWhitelist($sender, $username, 0)) {
71 display "Sender $sender would be whitelisted";
72 } elsif (() = OnBlacklist($sender, 0)) {
73 display "Sender $sender would be be blacklisted";
74 } elsif (() = OnNulllist($sender, 0)) {
75 display "Sender $sender would be nulllisted"
77 display "Sender $sender would be returned"