[Mimedefang] read domain list from config file

Steffen Kaiser skmimedefang at smail.inf.fh-bonn-rhein-sieg.de
Fri Mar 28 03:36:33 EDT 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Thu, 27 Mar 2014, Marcus Schopen wrote:

> for some of my domains I'd like to reject mails at a given spamscore of
>> =5. For some other domains at a higher score. Is it a good idea to read
> those domain names from different "external" config file instead of
> coding them hard into mimedefang-milter?
>
> sub filter_end {
> [...]
>  if (($Domain eq 'exmaple1.org' ||
>       $Domain eq 'example2.org' ||
>       $Domain eq 'example3.org') && $hits >= 5) {
>         if ($WasResent) {
>              action_discard();
>         } else {
>              action_bounce("Recipient refuses mail due to ...");
>        }
>  }

There are numerous ways:

a) DB_File, as Kris pointed out,
b) Storable
c) "require" an Perl-formatted file
d) CSV files and Text::CSV
e) plain text files
f) SQL backends
...

actually, I have all configuration stuff at the top the filter as hashes
or qr//s.

e.g. in your case

my %domainsDropHighSPAM = (
  'example.org' => 1,
  # ...
);

[...]

if(exists $domainsDropHighSPAM{lc $Domain}
  && $hits >= 5) {

- -or-

my $domainsDropHighSPAM = qr/\A(?:example\.org|example\.net|...)\z/i;
....
if($Domain =~ $domainsDropHighSPAM
  && $hits >= 5) {

- -- 
Steffen Kaiser
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQEVAwUBUzUmgpSHNCne69JnAQJsawf/e0P0vviYHHexlK7Q6OxxXiXjFEGbspW8
E4lbG8/0eBEpcsLy6qgfPoyvpJ4a1zpMPrS0dC/jwGlZgjiJzJXix6myI7TOAueD
M7MApVfCrWdCiyUcYnlitGHiiFGlqk8RUw8kIkCKZcJknvdjHmxupF3flYeWRDmF
qKPu8vVGYnAhzMdyzkm36e2fEUWTAg3B111X+MdR5LvNllxPuRdQKD7wQ0QpkjSj
0ZvGOOypQHPbVeA6eCXsiy+OlmEZtZDJjKKbfwXjuTROIMnmHexcY5xuca+YHvQI
3nh5LBFlRTgH2ZsYNdhDJXZx5sDwiknKZxJkKnHLSoe/z9nU64N2Sw==
=+7bq
-----END PGP SIGNATURE-----



More information about the MIMEDefang mailing list