Re: Recommended mail filters for use with mutt?
On Wed, Apr 02, 2008 at 02:20:33PM +0100, Chris G wrote:
>
> The main requirement is that the configuration file is very simple,
> not like procmail for example. My existing configuration file is
> simply one line per list with the list name and my alias for it (which
> is also the mailbox name). My filter program reads this file and uses
> it to route the mail to the right mailbox, my muttrc uses the same
> file to set up aliases, lists and subscribe lines.
>
> What do others here use, any recommendations that I might find useful?
I use a combination of a script and control file such as you describe,
which is interpreted by a script in my own scripting language. (hey,
you asked.)
The file contains various keys and actions. The keys might include
things like "from-address" or "sender-address" or "list-id" (and their
values), and the actions might include things like built-in known
keywords preceded by a '/', folder names enclosed in square brackets, or
script fragments bound by curly braces. The action field can also
include a priority (as a / keyword), such that if multiple keys match,
the best priority wins.
Most of the lines are very simple, specifying only a folder name in
brackets or the simple keyword "/keep". Real examples include:
list-id:dhcp-server.isc.org::[M/dhcp-server]
list-id:dhcp-users.isc.org::[M/dhcp-users]
list-id:dovecot.dovecot.org::[M/dovecot]
return-path-address:owner-tourbus@xxxxxxxxxxxxxxxx::/keep
to-localpart:abuse::[M/abuse]
cc-localpart:abuse::[M/abuse]
to-localpart:webmaster::/p1:[M/role]
sender-address:owner-nanog@xxxxxxxxx::/keep
The /p1 above is an example of the priority keyword specifying priority
1; it only is invoked if something else didn't match (implicitly with a
priority 0).
As I say, this is all interpreted by my delivery script, which means
that if I have anything that can't be handled by that file, I can
put it in the script instead of in the file. But the file handles an
awful lot of cases.
For mutt-users, the entry is:
sender-address:owner-mutt-users@xxxxxxxx::sieve { \
if not exists "Mail-Followup-To" { \
addheader "Mail-Followup-To" "mutt-users@xxxxxxxx"; } \
keep; }
#
The handling of this is done by a "hdrctls" script, an oldish version of
which is described here:
http://www.mvmf.org/mvmda/examples/hdrctls.shtml
and which is invoked from my main delivery script something like this:
@include "hdrctls.mfl"
sieve {
[ some special-case stuff here ]
/* Do our header controls database checks */
elsif C { hdrctls(); } {
stop;
}
[ more special-case stuff follows ]
}
Anyway, my answer seemed close enough to the question that I figured
I'd give it :) I've been using this setup for well over two years
and I find it quite handy.
-mm-