Re: how to kill mail threads i dont care about - someone w procmail skill?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mail Lists wrote:
>  Every once in a while I want to not read any posts or any followups
> when they are initiated by a certain person - or on a specific topic/
> Topics are easy to killfile coz we only need to match the subject.
>
>  Anyone got any ideas (procmail probably simplest) how to kill an entire
> mail thread if that thread is started by a specific email address ?

I've got one, and it looks quite a bit like what you outlined below in
psuedo-code. ;)

In my procmail config, I have these two recipes:

# drop mail from anyone in the killfile
:0 W
* ? formail -x"From" -x"From:" -x"Sender:" -x"Reply-To:" -x"Return-Path:" \
    | egrep -is -f $HOME/.procmail/killfile
{
    # add it to the killthread cache
    :0 Wic: killthread.lock
    | formail -D 40960 $HOME/.procmail/killthread.cache

    :0
    killfiled/
}

# drop threads started by anyone in the killfile
:0
* ? formail -c -x 'References' -x 'In-Reply-To' | thread-kill
killfiled/

The thread-kill script is a little bit of python:

#!/usr/bin/python

import os
import sys

verbose = False
if len(sys.argv) > 1:
    if sys.argv[1] == '-v':
        verbose = True

cache = os.path.expanduser('~/.procmail/killthread.cache')
if not os.path.exists(cache):
    raise SystemExit(1)

killed = [i for i in open(cache).read().strip('\x00').split('\x00') if i]
if verbose:
    print killed
    print

msgids = [i for l in sys.stdin.readlines() for i in l.split() if i]
if verbose:
    print msgids
    print

for m in msgids:
    if verbose:
        print 'checking if %s matches...' % m,
    if m in killed:
        if verbose:
            print 'yes'
        raise SystemExit(0)
    elif verbose:
        print 'no'

raise SystemExit(1)

My $HOME/.procmail/killfile generally just contains a few email
addresses, though it could contain regular expressions if more
flexibility is desired.

>  I think the logic could be something like ( there may be better
>  ways to do this)
>
>   If (<from> matches <target>)
>          append Message-ID to message_id_list
>          junk message.
>
> Loop (ID from message_id_list)
>     If (any mail has References matching ID
>         junk message;
>
>
>  Of course message_id_list is a growing list and should probably be
>  culled every week (or something).

The beauty of using formail's -D option is that it will do this
culling for you, based on size.

Fortunately, I don't feel the need to use this very often, so I have
not gotten around to improving it much in a long time.  One minor
improvement I intend to make some afternoon is to add a mutt macro to
drop message-ids for threads I want to die directly into the the
killthread cache.

-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The most useful piece of learning for the uses of life is to unlearn
what is untrue.
    -- Antisthenes

Attachment: pgpMd2JdtVFa6.pgp
Description: PGP signature

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux