procmail
[Top] [All Lists]

Possible solution >> Re: IMAP filtering, how to mark my own messages read

2005-10-10 10:13:33

(For those who don't remember the thread and don't keep old list  
mail, see:

http://mailman.rwth-aachen.de/pipermail/procmail/2005-August/022973.html

The basic problem being how to mark IMAP messages as READ when using  
MAILDIR)


I have figured out at least a possible workaround for this.  It's a  
little hackish, but I'd like folks' opinion of this idea.

The filenames have a set format, but the format does not have to be  
followed.(see footnote1)  If you can GUARANTEE that the filename will  
be unique, you can use whatever filename you want, it just HAS to end  
with

     :2,S

So I'm trying to think of the least CPU-intensive way to come up with  
a a unique identifier.  The best one I've come up with thus far is  
"date '+%s'"

:0
* ^Sender: procmail-bounces(_at_)lists\(_dot_)RWTH-Aachen\(_dot_)DE
{

     # if message is NOT from me, just file it as normal
     :0
     * ! ^From:(_dot_)*lists(_at_)tntluoma\(_dot_)com
     $MAILDIR/.INBOX.Procmail/

     # get exact time
     TIMESTAMP=`date '+%s'`

     # file directly as saved
     :0
     $MAILDIR/.INBOX.Procmail/cur/$TIMESTAMP:2,S

}

Of course this adds a level of complexity to each recipe... but it's  
time spent once to update the .procmailrc and time saved each time I  
don't open a mailbox thinking there is an unread message, only to  
find out it was from me.

Anyone have any thoughts on this?  Is there a better/easier way to  
get a unique identifier?

TjL

ps - I am testing the above recipe with this message



footenote1:

     I found this out when I had a HUGE folder of messages with a lot  
of duplicates.  I ssh'd to the server, cd to the appropriate  
directory, and then issued this command:

for i in *
do
ID=`grep -i "^message-id: " "$i" |awk '{print $NF}' | tr -d '<|>'`
mv -vf "$i" "$ID"
done

which looked at each message, found the message-ID, and renamed the  
file to the message-id (NOTE: if this had been a mission-critical  
mailbox I would have used this:

for i in *
do
SUM=`md5sum $i | awk '{print $1}'`
mv -vf "$i" "$SUM"
done

which would have been more CPU intensive (I think) and would have  
risked missing some duplicates if there was even a slight  
difference.  The Message-ID was effective, but it's possible (however  
unlikely) that there might have been a way that the script could have  
gotten confused, especially if there was a message with a lot of  
Message-ID: lines.  In this case there was little to no chance that  
would happen, so it was safe for the purposes of this example.

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail