use File::Temp qw (tempfile);
use Net::Domain qw (hostdomain);
-use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../../lib";
+use lib "$FindBin::Bin/../lib";
+use lib "$FindBin::Bin/../../lib";
use MAPS;
use MAPSLog;
my $execute = 1;
my $userid = $ENV{USER};
-my $logpath = "$FindBin::Bin/../log";
-my $logfile = "$logpath/debug.log";
-my $forwardto = $ENV{MAPS_FORWARDTO} || 'adefaria@gmail.com';
-
# For some reason I'm not parsing messages correctly but it only seems to
# happen when the message is piped in from the MTA. This routine will
# temporarily save the messages in a file.
while (!eof *$msgfile) {
my ($sender, $sender_long, $reply_to, $subject, $data) = ReadMsg (*$msgfile);
- #if ($forwardto) {
- # Forward a copy
- #open my $mail, '|', "/usr/lib/sendmail $forwardto"
- #or die "Unable to open pipe to sendmail - $!";
-
- #print $mail "$data\n";
-
- #close $mail
- #or die "Unable to forward email to $forwardto - $!";
- #} # if
-
my ($onlist, $rule, $sequence, $hit_count);
# Algorithm change: We now first check to see if the sender is not found
if ($onlist) {
verbose "Blacklisting $sender";
- my @msg = split /\n/, $data;
- Blacklist $sender, $sequence, $hit_count, @msg;
+ Blacklist(
+ userid => $userid,
+ sender => $sender,
+ sequence => $sequence,
+ hit_count => $hit_count,
+ data => $data,
+ );
+
next;
} # if
# Return processing:
verbose "Returning message from $sender";
- ReturnMsg $sender, $reply_to, $subject, $data;
+ ReturnMsg(
+ userid => $userid,
+ sender => $sender,
+ reply_to => $reply_to,
+ subject => $subject,
+ data => $data,
+ );
} # while
} # ProcessMsgs
'verbose' => sub { set_verbose },
'debug' => sub { set_debug },
'execute!' => \$execute,
- 'forwardto=s' => \$forwardto
) || Usage;
my $msgfile;
if ($ARGV[0] and $ARGV[0] ne "") {
- open $msgfile, $ARGV[0];
+ open $msgfile, '<', $ARGV[0];
- if (!$msgfile) {
+ unless ($msgfile) {
Error "Unable to open file ($ARGV[0]): $!\n";
exit 1;
} # if
verbose "Starting MAPS....";
-my ($username, $user_email) = SetContext $userid
+my %userOptions = SetContext $userid
or die "$userid is not a registered MAPS user\n";
-ProcessMsgs $msgfile, $username, $user_email;
+ProcessMsgs $msgfile, $userOptions{name}, $userOptions{email};
exit 0;