vpopq_tcp (Robert Schulze <rob at rob-schulze.de>)
This package includes client and server to check whether a given recipient is valid for a mail host, preferrably on qmail-based systems.
The server speaks a bit vpopmail API and does some checks on qmail-related files. It has to be used with tcpserver/(x)inetd and can easily be used by any simple client program.
The client is specific to a qmail+spamcontrol mailsystem, handling incoming mail.
Spamcontrol (>= 2.5.23) is able to drive any binary to check if the recipient is valid, this extension is used by the client.
Installation
Download and unpack the archive, then edit the Makefile.
Have a look at the strings given as library (-L...) and include (-I...) paths.
Server
Edit vpopq_server.c and modify the values of QMAIL_ASSIGN and VPOPMAIL_BASEDIR to your needs.
QMAIL_ASSIGN represents the full path to the file "users/assign" below your qmail basedir.
VPOPMAIL_BASEDIR means the path where vpopmail is installed.
To build the server, you will need gcc, libmysqlclient, libvpopmail.
$ make server
... if everything works, the result is a binary called vpopq_server.
Setup tcpserver - or whatever TCP daemon you want to use - to drive vpopq_server on
your magic port. A sample script to invoke tcpserver is included in the archive.
Conversation is quite simple and may be adapted by any client program:
Just send "foo@example.com\n" to the server, and it will send back one character as response and exit:
?: an error occured (invalid address, ...)
1: the address "foo@example.com" is known to the local mail system
0: the address "foo@example.com" IS NOT known locally
Beware if you try to use telnet to test the server, you will send "foo@example.com\r\n" in most cases, which will always fail.
The server does the following to determine if the recipient is valid:
ask vpopmail user and alias database (via vpopmail-API)
scan users/assign (qmail) for the path of the domain
check if domain has a catchall account (»vdelivermail '' delete|bounce-no-mailbox« NOT present in .qmail-default)
check if there is a file .qmail-foo (and all other dash-extensions to the address, e.g. when using ezmlm-mailinglists)
Client
$ make client
... if everything works, the result is a binary called vpopq_client.
You may put the binary to /var/qmail/bin, but you have to edit the file /var/qmail/recipients.
Maybe try the client with one domain at first:
If a mail to example.com arrives, this will tell qmail-smtpd to invoke vpopq_client which will query the vpopq_server on host 10.23.42.5 port 10001.
Being quite pessimistic, mail will only be rejected when the client receives a valid negative answer, on other cases (valid address or error), delivery is permitted.
If the connection to the server times out (2 seconds), the client will abort with a positive response.
Notes
This has been tested in production environment.
Use it WITHOUT WARRANTY, but don't bother about editing Makefiles and sources.
Known limitations
server accepts addresses with a length of 255 bytes max
server reads only up to 512 bytes from the .qmail-default file to look for vpopmail behaviour