procmail
[Top] [All Lists]

Re: Filtering already saved messages

1998-05-18 23:27:17
On Mon, 18 May 1998 10:20:33 -0400 (EDT), Matt Cortes
<link(_at_)alpha(_dot_)pulsar(_dot_)net> wrote:
One question I'm wondering..  I've got some older backedup mail too that I
might want to reprocess back into my main mail.  Now that I have procmail
that makes it pretty damn easy but of course the older mail I have has
literally thousands of messages I already have in my main mail.  Is there
anyway I can create a filter that would look at my old mail..  compare it
to my main mail and copy over only messages I don't already have in there?

Formail has an option to do duplicate exclusion. You need to get the
message-id:s of the messages you already have in your inbox into the
message-id cache file (and perhaps even include a recipe in your
regular .procmailrc to update the file each time a new message comes
in) and then in the procmailrc you use to split out the old messages,
skip anything that is already in the message-id cache.

Reading the formail and procmailex manual pages left as an exercise :-)

Also on another note..  If I eventually do decide to process some old mail
into my main mailboxes in the future..  Is there a way I can resort my
mboxes so that the messages are in order from time recieved (last message
being most recent)?  I don't want to have a bunch of old mail at the
bottom of my mbox.  And the client sorting it temporarly during reading

This is not necessarily trivial. It's been discussed here on the list
from time to time but none of the solutions I've seen have struck me
as particularly elegant. 

mush is a command-line mail client which has the commands to sort a
folder in date order. Search the archives for "mush". (Wasn't there
something like this in mh, too?)

You could use Procmail to split messages into date order somehow based
on the Date: header or the date in the From_ line. The problem with
Date: is that a lot of mail has invalid date stamps in this header,
and it's not necessarily always unambiguous. From_ will contain the
date of arrival on your machine (at least on the machines where I've
investigated this; I understand there is room for some variation here
too) which may or may not be perfect for your purposes.

GNU date is pretty good at getting "21st March 1998 I think" into a
machine-readable date stamp (such as seconds since the epoch); other
implementations of date(1) might be less capable. There are some
standalone date processors out there which you could try as well. A
program called mdate was posted to this list a year or two ago. I have
a link to it on the Procmail Links page at

    <http://www.iki.fi/~era/procmail/links.html>

and the searchable Procmail archive at Rosat -- in case you're
interested in previous discussions about these things -- is at

    <http://www.rosat.mpe-garching.mpg.de/mailing-lists/procmail/>

Hope this helps,

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>