procmail
[Top] [All Lists]

Re: Using Procmail to process header changes

2001-01-08 11:45:07
Each lead has my address in the cc: field, the original customer's address
in the to: field [...] . Can
procmail be used to [...] rewrite the header to put the
original customer's address in the from: field? [...]

Yes.

    # Some bozo-checks, then find the Original Customer Address (OCA)...
    # First, make sure it's not from root or a mailing-list.
    # Then, make sure this is the first time we're processing this mail.
    # Also, ensure that the cc: field has your address in it.
    # Finally, make sure there's a nonempty "To:" field, and store the
    #  contents in $OCA.

    :0
    * ! ^FROM_DAEMON
    * ! ^X-loop: yourname(_at_)yourdomain
    * ^cc: *\<yourname(_at_)yourdomain\>
    * ^To:[     ]*\/[^  ].*
    { OCA=$MATCH }

    # ONLY IF the preceding was executed, put $OCA into "From:" field, 
    # preserving the original "From:" as "Old-From:".  Also, we insert 
    # X-Loop: to make the above bozo-check meaningful.

    :0 Afhw
    | formail -i "From: $OCA" -A "X-Loop: yourname(_at_)yourdomain"

-- 
Neither I nor my employer will accept any liability for any problems
or consequential loss caused by relying on this information.  Sorry.
Collin Park                         Not a statement of my employer.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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