<<< Date Index >>>     <<< Thread Index >>>

Re: mutt and filtering



Hi,

* Patrick Shanahan wrote (2004-10-25 23:11):
>* Thorsten Haude <mutt@xxxxxxxxxxxxxx> [10-25-04 15:23]:
>> Don't use Procmail. 
>
>Why would you counsel someone to not utilize an application that you
>admit you do not understand and have not taken the time to try?

I have used it for two years or so. This was a few years ago, so I
forgot the more arcane syntax elements. That is, most of it.


>> There are alternatives that are much more friendly to new users. 
>
>Again, strictly opinion.

You don't consider ':0:' to be user friendly syntax, do you? What
about Procmail's ways to do ANDs and ORs?

Ultimately it is opinion, yes, but there is little evidence that
Procmail's ideosyncratic heap of syntax elements is meant to be
human-readable.


Let's make a test, shall we? Please translate the following part of my
Maildrop configuration into Procmail syntax:
- - - Schnipp - - -
gdbmopen("/home/yooden/.mutt/lists.db")

foreach /^(To|Cc): .*/
{
    foreach (getaddr($MATCH)) =~ /.+/
    {
        listbox = gdbmfetch(tolower($MATCH))
        if ($listbox ne "")
        {
            #   Drop any unsubscribe mails
            if (/^Subject: unsub?scribe$/ && $SIZE < 5000)
            {
                to /dev/null
            }

            to $MAILDIR/ML/$listbox
        }
    }
}

gdbmclose
- - - Schnapp - - -
A short explanation: This piece opens a database with an address/
mailbox hash map. It then iterates over recipients, reads the
destination mailbox from the database and delivers the mail. On the
way it discards misguided unsubscribe mails.


Something simpler:
- - - Schnipp - - -
killfile = "$HOME/.mutt/plonk.names";

sender = getaddr($FROM)

if (lookup($sender, $killfile))
{
    to $MAILDIR/admin/plonk
}
- - - Schnapp - - -
No explanation necessary I think except possibly for the format of the
killfile, which is simply one regex per line.


>>     if (/Subject:.*test*/)
>> 
>> Note that the first example would match 'testttttt' or 'tes'.
>
>And your note is incorrect, the above will *not* match 'tes', but will
>match anything following the line starting with 'Subject:' containing
>the char string 'test', ie: 'contestant' or 'another testing'.

Indeed, you are right. I only wanted to point out the nature of the
closing asterisk and neglected the first part of the regex. Thanks for
clearing that up!


>Procmail is easily implemented following the 'Quick Start' at:
>      http://www.ii.com/internet/robots/procmail/qs/

A Maildrop filter is easily implemented with any fleeting knowledge of
almost any programming langauge and five minute study of the manpage.


Thorsten
-- 
I was amazed today to find out how much Windows
can actually be used for useful things.
    - Donald E. Knuth

Attachment: pgpZwb7pgIljv.pgp
Description: PGP signature