I (the author) noticed once upon a time that the mail server I manage is blacklisted and in turn the sent mails reach the spam folders of the recipients. I wanted very much to get out of the black lists and came to the idea that the black listing is caused by the bounces sent from listserv. My wish was to create a system, that can reject mails during the SMTP dialog instead of letting listserv receive and then bounce them. The idea was to generate for every mailing list a Sieve script, that is evaluated at SMTP-time and rejects mails during the SMTP dialog, when feasible. Unlike other systems for mailing lists, where the not-good emails are either discarded or sent to the listowners, with this approach my listowners are not bothered with manually proceeding the (probably spam) emails, and enjoy more free time. At the same time no email is lost.
What is Sieve? A language for filtering emails. Developed by IETF within the Sieve Working Group, it allows to define rules for out-of-office messages, to put an incoming email in a folder, depending on the sender or the mail size, but most of all: Sieve/RFC5228 is a OS-independant way to say what emails shall be returned back to the sender, instead of ending in your spam folder.
So I ended writing two programmes: one to generate and upload the Sieve scripts, and one to evaluate them. After a while I noticed, that the features in the programme for script generation and upload can be used by other programmes for communication with listserv over the TCPGUI interface. I separated the code from the programme that communicates with listserv in a separate library and here it is.
The other two parts: the code for uploading the Sieve scripts and for the script evaluation can be found at http://mail.aegee.org/software (when published).
At the end I succeeded: now I reject a lot of emails during the SMTP dialog and my server is not blacklisted.