My RelayDB implementation in perl for MailScanner

Csillag Tamas cstamas at DIGITUS.ITK.PPKE.HU
Wed Nov 30 18:58:12 GMT 2005

    [ The following text is in the "iso-8859-2" character set. ]
    [ Your display is set for the "US-ASCII" character set.  ]
    [ Some characters may be displayed incorrectly. ]


(First of all forgive my English I am not a native English speaker and I
am a bit tired... But if I do not send this now I never will.)

I use MailScanner on a couple of machines for years so first I must say 'thank
you' to Julian Field and all the others who contributed to this project.

MailScanner is only one component of my mail filtering setup. So I thought
the others (maybe) can benefit how I extended MailScanner with Relaydb.

First, relaydb is Daniel Hartmeier's idea. I will not explain it
now. Read first if you are

Well if you are interesed be prepared to read the docs, read my
perl code (which is only about 140 lines btw.) and watch your syslogs for
errors. Be prepared it might not work out-of-the-box, without your work
and understanding.  If this kills your server, mails start bouncing or
from this time you start to have nightmares do not blame me.
It works for me: I use it here for half a year and it works as expected.

Still here? Then let the fun begin!  ;-)

In the beginning I was executing relaydb from Mailscanner (every time
calling a this binary and feeding it each mail's headers). Now I
implemented it as a function is So it is available as a
native perl code.

To use it:
1. You need perl's BerkeleyDB package (apt-get install libberkeleydb-perl on debian). 
2. You have to replace (or extend your current) with my attached file.
3. Set the following line in MailScanner.conf
Always Looked Up Last = &RelayDB
4. Create /etc/postfix/db/ with the right permissions
(test this! mailscanner must be able to write this directory!)
5. In postfix's set up
check_client_access cdb:/etc/postfix/db/ip_blacklist
under smtpd_recipient_restrictions.

If you use a Postfix version where cdb map type is not available change:
'postmap cdb:$exportfile' to your needs.
Well the method is not tied to any particular MTA just I use Postfix
here. The only thing you have to change is the way I export addresses to
a Postfix map.

If you are interested of have questions send feedback here (to the list).

"If you have an apple and I have  an apple and we  exchange apples then you
and I will still each have  one apple. But  if you have an idea and I have
an idea and we exchange these ideas, then each of us will have two ideas."
                 -- George Bernard Shaw

Pazmany Peter Catholic University The Faculty of Information Technology

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki ( and
the archives (

Support MailScanner development - buy the book off the website!

More information about the MailScanner mailing list