The first version is available at http://johannes.sipsolutions.net/edit/Projects/dovecot-dspam-integration/code I'm calling dspam for every message, that seemed easier for now. I will probably integrate Tom's idea about storing the messages until a cron-job picks them up at night by just storing signatures into mysql, in which case its easy to do with a single query: INSERT INTO new_spam (user, signature, isspam) VALUES (<user>, <signature>, <isspam>) ON DUPLICATE KEY UPDATE isspam = <isspam> with given values for <user>, <signature> and <isspam> and a key on (user, signature). For now, however, calling dspam for every message works good enough for me, and seems to work. Regards, Johannes