procmail
[Top] [All Lists]

Re: procmail newbie seeks help

1997-05-29 13:19:00
On Wed, 28 May 1997 12:15:12 -0500 (EST), Barry <barry(_at_)gslink(_dot_)com>
wrote:
that.  The program recieves the from line as the MAILFROM environmental
variable, parses the .addressbook file, exits with a -1 if there is no
match, or returns 0 if there is a match.  Here is what I put in my rc file

The syntax is slightly strange here, but while you're at it, you might
also want to change the program so that it either reads an entire
message on its standard input and grabs the From: field itself (if
it's a single-purpose program you only use for this), or reads the
From data on its standard input, or accepts the data as a parameter on
the command line (makes for a nicer interface if you intend to use the
program for other things as well). 

:0 cfw
{MAILFROM='formail -x From:' | doIknowyou}

Corrected syntax:

    :0 cw
    {
        MAILFROM=`formail -xFrom:` # note the backticks!
        :0
        | doIknowyou            # MAILFROM is inherited by child env
    }
  (etc)

Alternate version (read entire message on stdin):

    :0c
    | doIknowyou
  (etc)

Alternate version (read From data as command line parameter):

    :0cw
    {
        MAILFROM=`formail -xFrom:`
        :0
        | doIknowyou $MAILFROM
    }
  (etc)

As a mega-bronto bonus, here's a trickier version:

    :0c
    | formail -xFrom: | doIknowyou -nirapbwtoirsi
  (etc)

("nirapbwtioirsi" is short for "normally, I'd read a parameter, but
with this option, I read the From: data from standard input" :-)


experimenting with something I don't totally understand because I'm afraid
my mail will get sucked into a black hole.

You can set up a test bench where Procmail is not doing anything to
your "normal" mail flow. The simple command-line way is something like

    procmail DEFAULT="|" VERBOSE=yes rc.file

but while you're at it, you could actually set up a separate rc.file
solely for experiments. 
  (See <http://www.iki.fi/~era/procmail/mini-faq.html>, look for
"experiments.rc" in the index --- there! I plugged That Page again.)

from the environmental variable (did I do that right?) and returns a 0 or a
-1.

(Normal Unix programs return 0 for success and a +positive+ number for
failure. If you are unsigned, it will of course wrap back to a large
positive integer.)

/* 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>