procmail
[Top] [All Lists]

Re: Using Formail -d and procmail together

1996-08-15 08:26:09
As soon as I specify "-d 8192 .msgcache"  procmail refuces to sort
messages. the logged output complains that the expressions in the
procmailrc file are not found.  

Are you trying to use "formail -d" option at the *same* time as the
other, filtering options?  If so, then that may be the problem.

Formail -d *succeeds* when there is a message-id match (or "hit"); a
"success" in a program invocation from within procmail usually means the
mail has been "delivered" (regardless of whether or not the mail
actually went anywhere).  

Formail -d was written to "fail" when there is no message-id hit, so
that a procmail recipe would continue with the next recipe, delivering
or filtering the mail as appropriate.

Thus, the proper use of formail -d is in a recipe like this:

    # If formail succeeds on the cache hit, the mail will have been
    # "delivered", which, in this case, means "thrown away", and
    # procmail will stop processing.
    :0hW
    |formail -d 8192 .msid.cache

    # formail -d "failed", and we are still filtering..
    # ...more recipes...

Thus, the duplicate checking (message-id caching) feature is mutually
exclusive with the filtering options.  This is because when formail
finds a msgid-hit, it quits immediately with a zero status ("success"),
and when it does not find a msg-id hit, it exits with a non-zero status
("failure").

On the other hand, filtering succeeds when the header is inserted or
extracted correctly and an exit status of zero results.  Within a
recipe, this tells procmail that the filter or extraction succeeded.

Thus, if you try to use -d and a filtering option, the exit statuses
conflict: you cannot "fail" the message-id check and then "succeed" on a
header insertion or extraction.

To do this kind of combination, use filters in serial:

    :0hW
    |formail  -d 8192 .msgid.cache

    # Add headers
    :0fh
    |formail -I ...(other args)

    # Perform mail redirections
    :0
    * (some conditions)
    ! whomever

If you wish to split existing mail folders, and then filter out
duplicates, do something like this:

    formail -s procmail -m filter-file

where "filter-file" is your recipe file with the appropriate recipes to
be run over each piece of mail.  In this recipe file, you should place
the duplicate check recipe (as above).

Hope this helps.
_____________________________________________________________________
Alan Stebbens <stebbens(_at_)sgi(_dot_)com>      http://reality.sgi.com/stebbens

<Prev in Thread] Current Thread [Next in Thread>