procmail
[Top] [All Lists]

Re: complicated forward

2002-05-03 09:41:56
At 00:16 1970-08-30 +0000, Pavel Krijewkij did say:
How can I set up system so, that it forward my mail to other adress
, but
1) deleting subject

# delete subject
:0f
| formail -I Subject:

2) Inserting befor the main letter text some specific characters
(and after them, for example, stext of subject)

Assuming prior to deleting the subject, you had preserved it:

:0
* ^Subject:[    ]*\/[^  ].*
{
        SUBJECT=$MATCH
}

(I extract several commonly tweaked headers in this fashion, so all of my recipes have them available as variables)

Then you'd do something like so:

:0
| ( echo "SPECIALCHARACTER $SUBJECT" ; cat - ) | $SENDMAIL forwardaddress

(might be a useless use of cat)

You should of course consider adding and checking for X-Loop so you don't hammer yourself in the even that the message is forwarded back or bounced to you. Hit the archives (see the link at <http://www.procmail.org>) and search for "forward" and "X-Loop", and you'll find many posts on it.

So, to thread it together:

:0
* trigger condition
* ! X-Loop: yourxloopgoeshere
{
        :0
        * ^Subject:[    ]*\/[^  ].*
        {
                SUBJECT=$MATCH
        }

        # delete subject (also consider adding X-Loop stuff here)
        :0f
        | formail -I "Subject:" -A "X-Loop: yourxloopgoeshere"

        :0
        | ( echo "SPECIALCHARACTER $SUBJECT" ; cat - ) | \
                $SENDMAIL forwardaddress
}

If you want to prepend your bodified subject line without a newline, or add other text, see 'man echo' and 'man cat'.

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.

_______________________________________________
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>
  • complicated forward, Pavel Krijewkij
    • Re: complicated forward, Professional Software Engineering <=