On Mon, 2007-08-27 at 21:23 +0200, M. Fioretti wrote:
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/
So what happens if Dovecot sees the mail and moves it to cur/ before you had a chance to do that? If you really need to see all the new mails, then you'll need to figure out some way to handle that, such as add a new private flag for all processed messages.
Or you could deliver mails to some private maildir that Dovecot doesn't see, and process the messages from there to maildirs that Dovecot sees.
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?
mv, rm and ln are always safe. Just don't ever write to new mail files in new/ or cur/ directory, because then Dovecot might read partially written files. That means that "cp file new/" isn't safe, but "ln file new/" is.
Also make sure the filename is always unique.