Hello,
I have a postfix server which uses procmail as its delivery agent to deliver incoming messages to several maildirs. For several reasons, not really relevant here, I need to process/refilter/sort again the content of these mailboxes before delivering the messages to the _other_ maildirs which Dovecot sees and serves to local or remote imap users. Basically, I need to write some shell scripts that, from cron jobs, regularly do this:
foreach file in some_incoming_mailbox/new/ do #process the file and/or set some variable according to its content delete the file or mv it to some_other_maildir/new/
where the actual action and value of some_other_maildir is set every time by the "process the file" part of the script.
The part that I still miss is guidelines to do these things safely, that is without losing or corrupting messages or doing anything else that would confuse dovecot.
For example, under which conditions it is sure to move or delete (the Unix way, with mv or rm) a message from mailbox1/new/ to mailbox2/new, when the latter is served via dovecot to remote users?
What is advisable and most efficient? Use locks (how?), only work on file which are at least one minute old? Should I move the messages to tmp instead of new? What else?
Tips or pointers about this are very welcome.
Ciao, Marco