Exim DNSBL Caching with MySQL v0.0.1 - Initial version - Evren Yurtesen You should first create the sql table: CREATE TABLE dnsbllist ( firstdate datetime default NULL, lastdate datetime default NULL, ip varchar(15) NOT NULL default '', timeslisted smallint(2) UNSIGNED NOT NULL default '0', timesconnected smallint(2) UNSIGNED NOT NULL default '0', blacklisted tinyint(1) UNSIGNED NOT NULL default '0', UNIQUE KEY ip (ip) ) TYPE=MyISAM COMMENT='DNSBL List'; and create a user for exim: GRANT SELECT,UPDATE, INSERT ON database.dnsbllist TO 'eximuser'@'localhost' IDENTIFIED BY 'eximpass'; Then put the following lines to exim's conf file, somewhere at the beginning. These are the SQL statements which will be used: hide mysql_servers = localhost/database/eximuser/eximpass # Seconds before we expire the entries in dnsbl DB table DNSBLLIST_EXPIRE_TIME = 2*24*60*60 # Inserts the host IP as whitelisted into DB DNSBLLIST_WHITELIST_INSERT = INSERT IGNORE INTO dnsbllist \ (blacklisted,firstdate,lastdate,ip) \ VALUES('0',now(), now(),'${quote_mysql:$sender_host_address}'); # If the host IP is not blacklisted on re-check. Updates the 'lastdate' and set the host not blacklisted DNSBLLIST_UPDATE_WHITELIST = UPDATE dnsbllist SET \ lastdate=now(),blacklisted=0 WHERE ip='${quote_mysql:$sender_host_address}' # Updates the 'timeslisted' field on re-listings of blacklisted host IPs DNSBLLIST_TIMESLISTED_UPDATE = UPDATE dnsbllist SET \ lastdate=now(),blacklisted=1,timeslisted=timeslisted+1 \ WHERE ip='${quote_mysql:$sender_host_address}' # Updates the 'timesconnected' field on connection attempts from blacklisted host IPs DNSBLLIST_TIMESCONNECTED_UPDATE = UPDATE dnsbllist SET \ timesconnected=timesconnected+1 \ WHERE ip='${quote_mysql:$sender_host_address}' # Queries if the host IP is listed in DB DNSBLLIST_QUERY = SELECT blacklisted,ip,from_unixtime(DNSBLLIST_EXPIRE_TIME+unix_timestamp(lastdate)) \ AS expires, IF(DNSBLLIST_EXPIRE_TIME+unix_timestamp(lastdate)