What is greylisting?
See http://www.greylisting.org/, http://projects.puremagic.com/greylisting/

NOTES
=====
The database layout and code is IPv6 ready. Sadly, MySQL isn't. As soon this is
fixed, IPv6 is fully supported. Detailed information about IPv6 support for
inet_aton() at http://bugs.mysql.com/bug.php?id=3318.
The database layout uses triggers for calculating ip ranges of CIDR notations.
Thus MySQL 5.0 is recommended. However CIDR notations are also supported for
versions below 5.0 but have to be calculated on the fly. This has some significant
impact on the performance for large white-/blacklist tables (more than 5000 entries).

Compiling
=========
gcc -o greylisting greylisting.c -I/usr/include -I/usr/include/mysql -I/usr/local/include/mysql -L/usr/lib/mysql -L/usr/local/lib/mysql -lmysqlclient
strip greylisting

Greylisting configuration
=========================
Configuration file must be placed at <qmaildir>/control/greylisting
Example file is included in this package and has to be renamed accordingly
You can override all settings by using environment variables (see below)
A row must not exceed MAXCONFIGLINESIZE(=1024) characters!

mysql_host ........... MySQL hostname/ip
mysql_port ........... MySQL port
mysql_user ........... username for login
mysql_pass ........... password for login
mysql_db ............. database to use
block_expire ......... minutes until email is accepted
record_expire ........ minutes until record expires
record_expire_good ... days until record expires after accepting email
loglevel ............. loglevel (0=off, 1=fatal, 2=error, 3=warn, 4=info, 5=debug)

Enviroment variables
====================
- GREYLISTING
  _MUST_ be defined in order to start greylisting. Define in tcp-environ
  (e.g. :allow,GREYLISTING="")
- GLMYSQLHOST, GLMYSQLPORT, GLMYSQLUSER, GLMYSQLPASS, GLMYSQLDB
  GLBLOCKEXPIRE, GLRECORDEXPIRE, GLRECORDEXPIREGOOD, GLLOGLEVEL
  See configuration file notes above

Example qmail-spp configuration
===============================
[rcpt]
plugins/ifauthskip
plugins/greylisting

ifauthskip skips remaining plugins if user is authed and is recommended
This plugin is available at http://xs3.b92.net/tomislavr/qmail.html

Cleanup
=======
This packages includes a simple shell script (greylisting_cleanup.sh) which
cleans expired entries. You should run this hourly (e.g. via cron).

History
=======
2011-06-14 (0.3)
* add support for BATV (supported schema: prvs=HASH=user@domain.tld + prvs=user/HASH@domain.tld)
* fix a few minor compiler warnings
2009-09-23 (0.2.5, 0.1.5)
* fixed printing CRLF instead of LF to stdout (captured by qmail-spp) which
  results in printing CRCRLF to the sender. As far as we know only Novell
  Groupwise has troubles with this sequence but it's incorrect anyway.
  Thanks to Frank Koehlert for pointing this out
2008-01-04 (0.2.2)
* fixed segfault if rcpt_to doesn't contain a domain
* GLLOGLEVEL from environment now precedes loglevel from config file
2007-12-03 (0.2.1, 0.1.1)
* fixed wrong operator precedence in white-/blacklist query
  causes record_expires-field to be ignored if entry is recipient/domain based
2007-11-30
* fixed/swapped ip-match comments/documentation in check_greylisted()
  /24-subnet-matching is still default. updated both versions
2007-11-14
* fixed small typo. updated both versions
2006-12-14 (0.2)
* support for CIDR notations
* new sql scheme for white-/blacklists
* MySQL 5.0 is now recommended in order to use triggers (see NOTES)
* new loglevel support, removed obsolete debug variable
2006-12-7 (0.1)
* rewrote for qmail-spp compatibility
* configuration file support
* various improvements (mysql, ipv6, ...)