[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: procmail postprocess directory in Maildir format howto?

At 1149817191 past the epoch, mlaks wrote:
> How do I run procmail on [a Maildir] to separate out the
> files to other subdirectories.
> the crucial line is formail -s procmail <.newmail &&

the -s flag to formail splits the input up into seperate
mail messages and invokes the selected program (here,
procmail) with each message piped into a separate

As Maildir already has one file per message, all you need to
do is invoke procmail once per mail message. Something like
the following shell:

  find $YOURMAILDIR/{cur,new} -type f | while read file; do
    procmail < $file

Note that you probably want to be absolutely sure that
procmail doesn't put its output into the maildir you are
reading as input.

If you want to run this periodically and don't want to send
a message to procmail more than once, just move or delete
the file once it has been piped to procmail, like this:

  for dir in cur new; do
      find $INPUTMAILDIR/$dir -type f | while read file; do
        procmail < $file
        mv $file $PROCESSED/$dir
        # or: rm $file

For suitable values of $INPUTMAILDIR, $PROCESSED.

Jon Dowland

Reply to: