procmail
[Top] [All Lists]

Re: Can procmail be used to move mail between folders?

2001-07-31 09:11:13
On Tue, Jul 31, 2001 at 08:55:43AM +0100, Tim Allen wrote:
1. The imap server is wu-imap running on RH7.1. Is there any way to lock
sentfolder while performing this action to prevent wu-imap from adding to
the sentfolder while I'm passing it through formail? Or is it a matter of
running the cron job at 2.00 am on the assumption that everything's quiet
then? I've been looking at lockfile but can't see that's relevant to this.

2. I want to *move* entries from sentfolder, not just copy them. I can see
two ways of doing this. Either remove sentfolder after passing through
formail, and re-initialize. Or use formail a second time as a filter to
change the X-Status: header to D. Both these throw up the locking question
again as there's the risk here of losing messages if sentfolder is added to
while doing this.

Since formail won't modify the source file, the latter wouldn't work anyway.
You'd have to overwrite the original file with the output of formail, which
amounts to the same thing as removing the file and recreating it.

Moving sentfolder to a new file name would solve both problems. Move the file,
touch the original file name to create it, then process the sent folder under
it's new name. The server will append new incoming messages to the brand new
file (which you'll process on the next run). You can simply delete the new
(old) file when you're done processing.


# mv sentfolder sentfolder.old
# touch sentfolder
# formail -s procmail -m sentrc < sentfolder.old
# rm sentfolder.old

The only thing to worry about here is if you will be moving sentfolder to a
different partition. If the file will be staying on the original partition you
should have nothing to worry about. If it moves to a different partition,
you'll need to check that you don't try to move it until the server is done
appending, if it was appending. (Which means you still run into question #1,
but only if you're changing partitions.)
UW has a discussion of locking in docs/locking.txt in the source tree for
UW-IMAP. Unfortunatly it is beyond my mental capacity to parse at this hour,
and appears to be a general discussion of the issue, and a lot of "this is how
we do it on this type of system, using this type of mailbox" kind of thing.

-- 
Every man should know how to make at least one drink from a foreign country,
preferably one taught to him by a local female with whom he has had a
complicated, unresolved, and quite possibly dangerous dalliance.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail