procmail
[Top] [All Lists]

Re: processing inbox maildirs with formail

2007-08-27 08:32:04
On Mon, Aug 27, 2007 07:27:28 AM -0700, Bart Schaefer
(barton(_dot_)schaefer(_at_)gmail(_dot_)com) wrote:

Why is it necessary to first deliver to inbox.waiting with procmail,
and then reprocess the messages with procmail again?

For several unusual reasons. I didn't explain them in detail because
they're all very particular to my (desired) setup and not really
relevant to procmail. I could write a summary if somebody is really,
really interested, but the procmail/formail problem is all as I
described it.

In any event, formail works (and is necessary) only on flat-file
mailboxes, not on one-message-per-file directory mailboxes. For
maildirs, you will need to use some other tool to select the
messages (files in inbox.waiting/new) which ought to be fed back to
procmail again.

I had already discovered part of this after my first message. I am
working on this problem right now, and the closest I am to the
solution, but not there yet, is:

##################################################################
#! /bin/bash

cd /the/maildir/base/directory/
for file in cur/*
  do
  /usr/bin/formail -s /usr/bin/procmail -m test/rcfile.rc < $file
  #rm or mv $file
  done
for file in new/*
  do
  /usr/bin/formail -s /usr/bin/procmail -m test/rcfile.rc < $file
  #rm or mv $file
  done

#################################################################

where rcfile.rc looks like:

#################################################################

SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/bin
MAILDIR=/all/mail/base/
LOGFILE=/var/log/procmail_test_logs/PROCMAIL.log
LOGABSTRACT = "all"
VERBOSE     = "on"
DEFAULT     = "$MAILDIR/.test_output/"

#several recipe re-filter and process the messages...


#################################################################

with respect to your other explanations, I had already discovered (or
more exactly, remembered by experiment) doing this that procmail
leaves the original mail where it was and leaves an *extra* copy of
everything which didn't fit in the recipes into DEFAULT. So right now
I am tempted to put DEFAULT = /dev/null in the rc file and just
uncomment the "rm or mv $file" lines in the script above. In this way,
I would have all messages delivered, no extra copies, no messages
which are processed twice...

What do you guys think? Does it make sense or I am missing something
very important which will make me lose email, fill the disk or mess
things in any other way?

Right now I am testing all this on mailbox copies, everything seems
fine or to have a workable solution, but I'd really like some
confirmation from others before going live.

Procmail writes to files, but it reads from standard input, so it
has no intrinsic way of knowing that its input represents a message
that is already present in any mailbox it may eventually write.

Yes, I had forgotten this and it is clear again after your
explanations and some testing, thanks.

Marco
____________________________________________________________
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