procmail replacement in Python

François Pinard pinard at
Wed Jun 19 03:55:40 CEST 2002

[Gerhard Häring]

> I've recently looked into the procmail sources and run away screaming.

ROTFL!  If I remember well, the original author knew he had a peculiar
writing style, and was writing in some prominent file (either an FAQ or
the README, or something like) that his style was not to be discussed! :-)
I wondered if the new maintainer revised the sources or not, I did not check.

> I'd very much prefer a Python replacement to such badly written C code.

Is it bad style?  I never went as far as asserting that it was bad style,
because tastes may differ.  Yet in that case, I knew that tastes may differ
very widely. :-).

Surely, `procmail' successfully addressed difficult problems, and did it
rather solidly, with almost no bugs.  So, despite the writing style is rather
alien to mine, it surely had mysterious virtues.  I could not condemn it!

> Does anything exist that I can start from?

This has been discussed on 2000-02-07 on this list.  In particular:

Donn Cave <donn at> says:

   Anyway, it might be interesting in this context to look
   at Sift-Mail, a Tcl application from Lawrence Lundblade: and the Sieve language proposed as
   an Internet standard for mail filtering,

Bernhard Reiter <breiter at usf.Uni-Osnabrueck.DE> says:

   Just for completion, there is another newcomer in the mailfilter
   competion.  Still a greenhorn, but maildrop. Of course, who ever could
   get a C++ save. :)

Skip Montanaro <skip at> says:

   Worth noting that the procmail tips page at mentions Lua as a possible
   replacement for the procmail language (see the end of question 3.5).

> I've even contemplated not inventing yet another filter language, but
> just using plain Python functions.

`procmail' syntax is a bit opaque, but it seems to be very efficient, and
there is a great deal of experience which has accumulated over this syntax.
It might be difficult to raise a challenging competitor.  I guess that
one should overview all tools of this kind before tackling such a project.
There is also a lot of experience and solved difficulties in such tools,
portable locking and solid error recovery not being the least.

> If I do this, I'd like to replace fetchmail with getmail as well.

What is `getmail'?

> - writing it as a getmail plug-in
> - writing it as a standalone program to deliver to mailboxes a la
>   procmail
> - let getmail deliver to a temporary folder, then using my procmail
>   replacement to filter into the right folders, delete spam, etc.

My experience with `procmail' as a SPAM filter told me that it may get
frustratingly slow, when you use hundreds of filtering rules.  A few years
ago, I really pondered many alternative approaches, this would be a long
story.  In these days, for SPAM and virus filtering, I gave in and wrote
a Python tool which is good for me, but which would not be comprehensive
enough for publication.  However, there are also many SPAM filtering systems
around which have been published.  You might want to give a comprehensive
look into all these things, before adding yet another one.  Maybe! :-)
-------------- next part --------------

François Pinard

More information about the Python-list mailing list