procmail
[Top] [All Lists]

Re: AW: How to forward mail without changing Return-Path?

1997-07-29 08:07:00
On Tue, 29 Jul 1997 17:04:05 +0300 (EET DST), I wrote:
    :0  # add a c flag if you would also like to keep a copy
    * conditions, if any

(A clarification in case you're not at all familiar with Procmail
syntax: 
  Leave this out completely if you unconditionally want to forward all
messages to the fax gateway. If that's not what you want, you can
restrict them e.g. by forwarding only messages whose Subject: header
contain the words "I Am A Rock":

    * ^Subject:(.*\<)?i am a rock\>

This will permit any text before or after the keyword phrase. It will,
however, not match "qui am a rock" or "i am a rocker", thanks to the
funny-looking \< and \> codes.
  Or you can look for a string "To the fax gateway" at the first line
of the message after the headers:

    * B ^^to the fax gateway$

The $ confines this to being alone on the first line. All matching is
case-insensitive; if you want case-sensitive matching, add a D flag to
the :0 line, i.e. :0 D, at the start of the recipe.)

    {
        :0
        * ^Subject:[ ]*\/[^   ].*
        | ( echo "To: faxgateway(_at_)where-ever"; echo "Subject: $MATCH"; 
cat - ) \
            | $SENDMAIL $SENDMAILFLAGS -t
    }

Sorry, I wasn't paying attention. You need to echo another extra empty
line to separate your new headers from the old ones. This will FAIL
MISERABLY if you use my original proposal. 

While I'm at it, I'll give you a version which doesn't put a Subject
line in the headers for the fax gateway. The braces are also
unnecessary so I'm omitting them this time: 

    :0       # again, if you want to keep a copy, change to :0 c
    * conditions, if any
    | ( echo "To: faxgateway(_at_)where-ever"; echo; cat - ) \
      | $SENDMAIL $SENDMAILFLAGS -t

If you do want to keep the Subject:, here's how to do it without the
braces: 

    :0
    * conditions, if any
    * ^Subject:[        ]\/[^    ]*
    | ( echo "To: faxgateway(_at_)where-ever"; echo "Subject: $MATCH"; \
        echo; cat - ) | $SENDMAIL $SENDMAILFLAGS -t

This will in fact not forward a message without a Subject: line, but
those are rare. You should of course replace faxgateway(_at_)where-ever
with the correct address for the fax gateweay.

Finally, the funny stuff between brackets in the line that captures
the Subject: header is a space and a tab, in any order. This is to
skip any whitespace between the colon and the text you do want to
capture. You could of course capture it all just as it comes instead: 

    * ^\/Subject:.*

Right. Hopefully I shall not have to correct my corrections this time ;-/

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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