[Mimedefang] filter on header From:
Marcus Schopen
lists at localguru.de
Tue May 9 08:45:55 EDT 2017
Hi Kris,
Am Dienstag, den 09.05.2017, 10:51 +0200 schrieb Marcus Schopen:
> Is there a way to load the key-value hash table file only at
> start/reread/reload of mimedefang and not read it on each incoming email
> in filter_end?
Haha, we had a similar discussion three years a ago ;)
http://lists.roaringpenguin.com/pipermail/mimedefang/2014-March/037274.html
This is my mimedefang-filter now:
sub filter_initialize {
require DB_File;
use Fcntl;
tie %testhash_list, "DB_File", "/etc/mail/testhash.db", O_RDONLY;
}
sub filter_cleanup {
untie %testhash_list;
}
sub filter_end {
[...]
# get header From and compare to hash
my $fromaddr = $entity->head->get('From');
$fromaddr =~ s/.+<([^>]+)>/$1/;
$fromaddr =~ s/\s+$//;
if(exists $testhash_list{lc $fromaddr}) {
action_add_header("X-SpecialHeader", "$fromaddr is in
testhast_list");
}
The hash file is created with
makemap hash testhash.db < testhash.txt
The format of the hash file is just
myemailaddress at domain.de<TAB>1
What I don't understand is, why there is an ending white space on the
header From variable $fromaddr, so I have to trim it with
$fromaddr =~ s/\s+$//;
Ciao
Marcus
More information about the MIMEDefang
mailing list