procmail
[Top] [All Lists]

Re: Procmail filter for outgoing mail

1997-06-23 21:55:00
Chris Bidmead <bidmead(_at_)cbidmead(_dot_)demon(_dot_)co(_dot_)uk> writes:
I'm trying to write an outgoing filter that goes between my MUA and  
a second filter written by Tim Luoma that in turn evokes sendmail,  
and I'm not having much luck.

I'm using #! /usr/local/procmail in the first line and thus making  
my procmailrc file executable.

A couple of problems.  My MUA passes addresses in $@ to the prog it  
pipes to, which hitherto on my system has (successfully) been  
sendmail and, (latterly, also successfully) Tim's filter.  Obviously  
I need to preserve $@ in my own filter and pass it on.  But alas  
stuff like:

SHELL=/bin/sh
ARGS=$@

.....

| TimsFilter $ARGS

...doesn't seem to work.  $@ seems to be empty by the time it gets  
to the assignment.  Or maybe procmail just doesn't know how to  
handle the commandline args string.


Well, before 3.11pre4, procmail didn't handle unquoted $@ correctly, so
that's possibly part of the problem.  However, before you just run out
and upgrade (which you should do anyway), you should consider that this
setup doesn't handle quoted arguments correctly.  If there's a space for
file globbing character (*, ?, or [) in one of the arguments then this'll
bomb.  And don't think that spaces are impossible: if you replying you
may end up sending to the address

        Philip Guenther <guenther(_at_)gac(_dot_)edu>

That has to be one argument to sendmail, not three.

The solution is to put $@ in the action, double quoted.  You'll need to
make sure that procmail doesn't have to invoke the shell, so a very
simple action is necessary.

        | TimsFilter "$@"



The second thing I can't get right is probably simpler.  I know I  
can assign stuff like:

DEFAULT=<filename>

..where <filename> includes things like /dev/null or even |

But what I want to do is set up DEFAULT to be TimsFilter -- ie, an  
executable .  Something along the lines of:

DEFAULT ="| TimsFilter"

Sorry, no can do.  The recognition of the action type (pipe, forward,
or mailbox(es)) is done before variable expansion.


Philip Guenther