text/gemini
# Filtering email with filter(1)
Some time ago I was browsing through list of orphaned Debian packages^1. and encountered `filter` program with very promising description — "filter is one of the original mail filtering programs written for UNIX".
=> https://bugs.debian.org/wnpp ^1
It is much simplier than `procmail`, its manual page is *page*, not *manual*, while supporting almost anything I need:
* regex/substring matching of *Subject*, *To* and *From* headers
* built-in delivery into mboxes and any other develiery method via piping. It is important to me, since I use mmh^2 mail user agent, which uses its own mail storage format.
=> http://marmare.de/prog/mmh ^2
* support of filtering, based on length of message body. Not sure how well it copes with damned "content/alternative" messages.
Syntax of `filter` rules is much less cryptic and less verbose, than one of `procmail`. Compare
```
if (subject = "Foo") then save "/tmp/foo.mbox"
```
with much more verbose `procmail` rule.
```
:0:
*^Subject:.*Foo
/tmp/foo.mbox
```
Unfortunately, `filter` does not provide equivalence of two features of `procmail`, that are significant to my email workflow:
* Matching of arbitrary header. My email provider run SpamAssassin on
incoming emails and adds *X-Spam-Level* header. My `procmail` configuration uses this header to classify messages as spam. Probably, I could run SpamAssassin locally, but why bother, if settings of my email provider are fine for me.
* Handling of duplicate email. In cases when people reply to me and add mailing list into carbon copy, I receive two copies of email with same `Message-Id` header. It is distracting.
Both `filter` and `procmail` are long ~dead~ mature. Source code of `filter` is twice as short, if you care about such things. Half of that is regular expression engine, that is built it modern implementations of standard C library. Give `filter` a shot.
Definitely, `filter` would benefit from some care. Use standard regular expression engine, add support for *X-Spam-Level* header and here it is -- perfect email filtering solution. Maybe, one day, in my copious free time…
This content has been proxied by September (3851b).