On Thu, Feb 21, 2002 at 04:17:39PM -0600, Chad C. Walstrom wrote:
>         # Get rid of thos friggin' annoying Reply-To headers...
>         :0f
>         * $ LISTADDR ?? .
>         * ^Reply-To:.*
>         | formail -R "Reply-To" "X-You-Thought-You-Would-Make-Me-Reply-To"

Quick correction, in case any one has tried this yet and watched it
fail.  Remove the '$' between '*' and 'LISTADDR'.  It should look like
this:

    :0f
    * LISTADDR ?? .
    * ^Reply-To:.*
    | formail -R "Reply-To" "X-I-Have-A-Reply-For-You"

After thinking about it some more.  It's not necessarily list servers
that do this.  If your "To:" header and "Reply-To:" header match, then
something is amis.  It's an ambiguous assignment, and quite useless.
Better to use that as a comparison tool, however.

    # Test for Reply-To first.  If fails, skips next two tests.
    :0
    * ^Reply-To: *\/[^ ].*
    { REPLYTOADDR=$MATCH }

    # Execute this recipe if last was successful
    :0 a
    * ^To: *\/[^ ].*
    { TOADDR=$MATCH }

    # If last successful, filter the email, but wait for it.  If not
    # successful, pass on.
    :0 afW
    * TOADDR ?? REPLYTOADDR
    | formail -R "Reply-To" "X-I-Do-Not-Believe-I-Will-Reply-To"

The upside is that I'm assuming this should be much quicker.  It's
obviously simpler w/respect to the regex matching done.

Another tip to remember is that you can have any number of RC files for
procmail, and that you can include them using INCLUDERC.  My
procmailfile has many of these, but it also has a few conditional tests
that allow me to turn on and shut off the use of any given RC file.

    :0
    * ? test -f $PMDIR/replyto-fix.rc -a -f $PMDIR/do_replyto-fix
    { INCLUDERC=$PMDIR/replyto-fix.rc }

Let's say I wanted to make the new Reply-To header a variable.  I could
add that in before the INCLUDERC call:

    :0
    * ? test -f $PMDIR/replyto-fix.rc -a -f $PMDIR/do_replyto-fix
    {
      NEWREPLYTO="X-Reply-To-This-Wanker"
      INCLUDERC=$PMDIR/replyto-fix.rc 
    }

And in replyto-fix.rc, you'd have a shell-like default assignment:

    NEWREPLYTO="${NEWREPLYTO:-\"X-Reply-To-Matches-To\"}"

Procmail is quite powerful with simple syntax.  Just remember to read
your man pages.

HEH.  In hindsight.  If you want to save yourself 4k for the filesize of
"do_something", you could place a variable at the top of your
~/.procmailrc and test for it like so:

    DO_REPLYTO_FIX=1

    :0
    * DO_REPLYTO_FIX ?? .
    * ? test -f $PMDIR/replyto-fix.rc
    { 
      NEWREPLYTO="X-Reply-To-This-Wanker"
      INCLUDERC=$PMDIR/replyto-fix.rc 
    }

To undefine a variable, just list it:

    DO_REPLYTO_FIX

* Chewie goes off and fixes his procmailrc file and saves a whole 40k.

-- 
Chad Walstrom <chewie at wookimus.net>                 | a.k.a. ^chewie
http://www.wookimus.net/                            | s.k.a. gunnarr
Get my public key, ICQ#, etc. $(mailx -s 'get info' chewie at wookimus.net)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://shadowknight.real-time.com/pipermail/tclug-list/attachments/20020221/786bd6a5/attachment.pgp