smeserver-learn/root/usr/bin/LearnInWL.pl

37 lines
895 B
Perl
Raw Normal View History

#!/usr/bin/perl
#############################################################################
#
# This script has been developed
# by Emmanuel Jooris at http://sme.firewall-services.com
#
# Revision History:
#
# June 06, 2008: : Initial dev version
#############################################################################
use Email::Simple;
use esmith::ConfigDB;
use warnings;
$/=undef;
open(MAIL,$ARGV[0]);
$file = <MAIL>;
close(MAIL);
$/="\n";
my $email = Email::Simple->new($file);
my $from_header = $email->header("From");
my $sadb = esmith::ConfigDB->open("spamassassin")
or die "Could not open SpamAssasinDB ( reason : )".esmith::DB->error." )\n";
if ($from_header =~ m/<.*?>/) {
$from_mail = $&;
$from_mail =~ s/<//;
$from_mail =~ s/>//;
}
elsif ($from_header =~ m/@/) {
$from_mail = $&;
}
$from_mail =~ tr/[A-Z]/[a-z]/;
$sadb->set_prop("wbl.global",$from_mail,"White");