procmail
[Top] [All Lists]

Re: archive old mail (formail?)

1997-03-26 14:14:58
Does anybody have a script, that I assume would use 
formail, that will take a list of files (my pine mailboxes)
and archive messages more than "n" days old or something?

I'd love to find a simple way of doing this.  Unfortunately, there's
precious few programs out there that understand dates.  With close to 30
mailboxes receiving daily log output from over 4 departmental clusters, I
need some way to gracefully expire messages after they reach a certain
age.

Here are two solutions I've come up with:

(1) If you're inclined to coding, you can make fantasic use of an IMAP
server.  IMAP 4 servers have a find command that, among other things, let
you send commands like this:

  FIND BEFORE 26-Mar-1997

And return a list of messages.  You can then issue a delete command for
each message, and the world is a wonderful place.  I wrote a small C
program that was essentially a front end to the IMAP FIND command; it
allowed constructs like this:

  fmb -b ~/mail/procmail -Fbefore=26-Mar-1997 -K

To delete all messages received before 3/26/97.  It also allowed moving,
copying, counting, and flagging of messages.  I ran an imap4 server on my
local machine, to which this program would connect to work its magic.

Unfortunately, it has not proven to be especially robust, and I've since
abandoned it.  I keep thinking about delving into the c-client libraries,
but I haven't yet had the time.

(2) I have not actually tried this, but the 'mh' package has a command
called "pick" that will allow you to select messages from an mh mailbox
based on certain criteria, much like the IMAP FIND command.  You could:

        (a) Just use a procmail recipe to store all your incoming message
            in an mh-style folder, and then use the pick command from
            a script or a command line:

                rmm `pick +some_folder -before -05`

            (Pick returns a list of messages, and 'rmm' is the
            remove message command for mh mailboxes)

        (b) Use formail and procmail or one of the 'mh' utilities to
            split a standard Unix-style mailbox into an mh mailbox,
            manipulate as you see fit, and then repackage the result
            back into a standard mailbox.

Choice (a) would be fine for me, except that the IMAP server I'm running
doesn't support mh-style folders.  Since I'm frequently accessing my mail
from home via an IMAP client, this isn't an option.

Choice (b) just seems ugly.  Any thoughts or comments from others?  Is
there an IMAP server that understands mh mailboxes?

-- Lars

---
Lars Kellogg-Stedman * lars(_at_)bu(_dot_)edu * (617)353-8277
Office of Information Technology, Boston University

<Prev in Thread] Current Thread [Next in Thread>