Guide updated on 29th of February 2016

Implement validrcptto feature


The goal is to verify the RCPT TO argument, and reject (at SMTP level) messages which were being sent to non-existent addresses.

Qmail sources needs to be patched as described in Step 2. If you've followed the entire guide, this is already done.

aptitude install freecdb libcdb1 libcdb-file-perl libcdb-dev

Unfortunately, the freecdb package provides not all the commands from original D.J. Bernstein tar file (cdbmake-12 and cdbmake-sv are missing). We have to compile to have the missing commands.

cd /downloads/
gzip -dc < cdb-0.75.tar.gz | tar -xf -
cd /downloads/cdb-0.75
echo 'gcc -O2 -include /usr/include/errno.h' > conf-cc
make
make setup check

Then install mkvalidrcptto script and test all used libraries are loaded correctly:

cp /downloads/scripts/mkvalidrcptto /usr/local/bin
chmod 755 /usr/local/bin/mkvalidrcptto
perl -cwT /usr/local/bin/mkvalidrcptto

You should see something like that:

mkvalidrcptto syntax OK

We can now create a first CDB file containing all the created accounts

cd /var/qmail/control/
mkvalidrcptto > validrcptto.txt
cdbmake-12 validrcptto.cdb validrcptto.tmp < validrcptto.txt

We finally will start using it.

To achieve this, edit the file /var/qmail/supervise/qmail-smtpd/run and uncomment following options :

VALIDRCPTTO_CDB="$VQ/control/validrcptto.cdb"
VALIDRCPTTO_LIMIT=10
VALIDRCPTTO_LOG=2

Automate the update of valid adress list

cp /downloads/scripts/update-validrcptto /etc/cron.hourly/
chmod +x /etc/cron.hourly/update-validrcptto

If you need each change to be reflected immediately, do not put script in cron but compile vpopmail with the --onchange feature.

In such case, read the file /downloads/vpopmail-5.4.33/doc/README.onchange for more information

Restart the service

qmailctl restart

External reference

http://qmail.jms1.net/patches/validrcptto.cdb.shtml
http://www.x86linux.org/wiki/index.php/Valid_RCPT_TO_for_qmail

List of optional features


Users comments
Yalcin - 01/01/2013 16:42

Hi @Claudio

You can use cdb-0.75.tar.gz that you download to /download directory.

cd /downloads/
tar zxf cdb-0.75.tar.gz
cd cdb-0.75
sed -i '/int errno/{s/^/\/* /;s/$/ *\//;G;s/$/#include /;}' error.h<
make
make setup check

now cbdmake-12 is installed.

Claudio - 19/12/2012 03:06

Good evening, i have a problems with cbdmake-12 where i can find ?

Hipo - 19/10/2012 14:18

Hi Thibs,

For amd64 you can also just follow totorial as pointed by you but change i386 with amd64 for dpkg install:

I've recently explained this in one of my comments.

http://pc-freak.net/blog/pcfreak-2-days-downtime-expression-great-alex-sister/comment-page-1/#comment-58080

Best,

Georgi

Tom delombarde - 22/04/2012 02:20

The problem with using vpopmail's onchange function is that it doesn't remove users from the database. Because of this, you should probably use both the onchenge (to immediately add users) and the cron script (to eventually remove users.

From the onchange docs:

"Commands that add or update call the script after making their changes.  Commands that delete something call the script before doing the delete."

Gato - 07/08/2011 02:52

mkvalidrcptto > validrcptto.txt
Cannot continue.

solved with cat /var/qmail/control/me > /var/qmail/control/locals


Color Coded Qmail Installation Key
  Regular Black Text     Qmail installation notes and summaries by the author.
  Bold Black Text     Commands to be run by you, the installer.
  Bold/Regular Red Text    Vital and/or critical information.
  Regular Blue text     Denotes helpful tips and hints or hyperlinks.
  Regular Orange Text     Command line output.
  Bold/Regular green text     Denotes the contents of a file or script.