procmail

Using .forward to preprocess incoming email?


I have no previous experience with procmail. I have written a filter to repair broken headers in certain emails that I receive. I need to set up my .forward file to run the repair filter without breaking the existing email processing.

Let's say that the current .forward file is

|IFS=' ';exec /usr/local/bin/procmail #username

Would I add another line above it in the file, or would I interpose the filter in the existing line like

...exec filter | /usr/local/bin/procmail #username

EDIT: I don't think that the single-line process would work, because the file in the .maildir/cur would still be bad. I need to modify that file, preferably as it lands in ./cur.


Solution

  • Just run the filter immediately at the start of your .procmailrc. One of the important features of Procmail is that it make this (comparatively) easier and safer than doing voodoo directly in your .forward (which isn't portable between MTAs and platforms anyway; yours looks like a legacy Sendmail one, but who knows).

    :0fw
    | filter
    

    Procmail typically runs before anything is written to Maildir/cur but this also depends on what exactly invokes Procmail and how.