procmail
[Top] [All Lists]

Re: Forward based on To: in body...

1998-04-21 12:47:35
Ricardo Stella asked,

| I have an account set that should do the following:
| 
| * Process e-mail from a specific list (external) of valid addresses
| * Search for lines that start with "To: email(_at_)address(_dot_)here" in the 
BODY
| of the message, and forward to these receipients.
| 
| I'm starting to use procmail, that's why I need the help.
| 
| As an Example, the Body of the message will be like this:
| 
| text
| text
| ...
| To: one(_at_)email(_dot_)address
| To: two(_at_)another(_dot_)address
| ...
| To: last(_at_)maximum(_dot_)30(_dot_)address
| 
| more text
| more text

Now, if there were just one permitted To: line in the body, I'd say to
extract it into $MATCH, like this (first brackets enclose space and tab;
second brackets enclose caret, space, tab):

:0 flags
* other conditions
* B ?? ^To:[    ]*\/[^  ].*
! "$MATCH"

But there could be more than one, and moreover we probably don't want the
downstream recipients to see each other's addresses, so let's try something
like this (untested):

:0b flags
* other conditions
* B ?? ^To:.*[^         ]
forwardees=| formail -fzxTo: | sed 's/"//g;s/.*/"&"/'
 :0A
 | sed -e '1,/^$/b' -e '/^To:/d' | $SENDMAIL -oi $forwardees

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