procmail
[Top] [All Lists]

Re: Elm's filter equivalents, plz!

1998-11-23 10:29:58
On Mon, 23 Nov 1998 10:28:13 -0600, Sree Mokkapati
<sree(_at_)ec(_dot_)rockwell(_dot_)com> wrote:
I am trying to switch from elm's "filter" to procmail and I find the
syntax confusing and insufficiently documented[?]. I am mainly looking
for Procmail's equivalents for following "filter's" variables:
                    1] %r [sender's address]
                    2] %s [subject]
                    3] %t [time]

Procmail isn't really doing any parsing of the headers. You can match
these by regular expressions and use the \/ token to grab them into
MATCH one by one, though.

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

    :0
    * ^Date:[   ]*\/[^  ].*
    { DATE=$MATCH }

    :0  # This is probably not what you want
    * ^From:[   ]*\/[^  ].*
    { FROM=$MATCH }

What you probably want instead of that last one is something more like
this: 

    :0
    | ( formail -rt ; \
        echo "This is an automatic response to your message from $DATE about"; \
        echo "$SUBJECT" ; \
        echo "which was sent to an address which is going to cease to exist"; \
        echo "in the relatively near future. The correct address to use is"; \
        echo "<flesh(_at_)blood(_dot_)net>. Thank you for your cooperation."; \
        echo "(Your message has been forwarded to the correct address"; \
        echo "automagically, but this feature will stop working eventually.)" \
      ) | $SENDMAIL $SENDMAILFLAGS -t

I imagine it was something like this that you had in mind. This is
untested but pretty much run-of-the-mill. Check procmailex(5)

My ultimate aim is to design an autoresponder which while placing a copy
of the incoming message in user's "mbox" responds to sender notifying
change in my "domain name" if and only if the sender used the old domain
in his/her address. Currently I have aliases doing the job.

Sounds to me like aliases would be the right answer in the future,
too. You can't necessarily tell from the headers to which address a
message was sent. See <http://www.iki.fi/~era/procmail/mini-faq.html>

Perhaps you want to take a look at Martin Ramsch's filter to procmail
converter? 
<http://www.forwiss.uni-passau.de/~ramsch/Software/ef2p/index.phtml.en>

/* era */

-- 
.obBotBait: It shouldn't even matter whether    <http://www.iki.fi/~era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>

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