At 23:59 16-01-99 -0500, Jimmy Humphrey wrote:
How could I use a CGI script (perl 5) to do my filtering for whatever
reason with procmail? LIke if anybody sends a e-mail to x(_at_)x and
procmail catches it, then i use the cgi script to verify the sender is
correctly on the list and mail it to the masses?
Properly, CGI is "Common Gateway Interface" -- it is a program for use on a
webserver (or anything else implementing CGI, tho I don't happen to be
aware of anything except http daemons). It just happens to be you can
write them in perl, but by definition, a perl program is not simply a CGI
(nor is a CGI necessarily written in perl).
That said, yes, you can use a perl script (or really just about ANY
external scripting) from procmail, in a recipe rule (condition) or recipe
body (delivery/processing).
However, in your case, you could just as easily use stuff that already
exists - no new code writing except the procmail script itself. AAMOF,
possibly less overhead too.
Here's some stuff pieced together for this (but the rule itself isn't
something I use, and I presume you have a process for delivery in mind, so
I'm not detailing that).
# I do this in my main .procmailrc file before inclusion of everything else,
# so I have access to these variables without having to diddle them for
# every recipe that might need them.
:0
{
SUBJECT=`$FORMAIL -xSubject: `
TO=`$FORMAIL -xTo: `
FROM=`$FORMAIL -xFrom: `
SENDER=`$FORMAIL -rtzxTo:`
}
# likewise, I define paths to tools, although my .procmailrc also defines a
# specific path for various system utilities, I like to SPECIFICALLY define
# the path to certain programs to make sure I don't end up with something
# else, or that if a version gets changed, I can easily make a change which
# will globally affect my scripts:
FGREP=/usr/bin/fgrep
AUTH_FILE=$HOME/path-to-file-with-authuseraddresses
# this rule is conditioned on:
# Addressed TO your listthing .. AND
# The AUTH_FILE EXISTS and isn't zero length .. AND
# the FROM component, piped to fgrep to compare, case insensitively against
# lines in AUTH_FILE and that result returns TRUE (found) .. THEN
# do whatever delivery mechanism you have in mind
:0
* ^TOdistributionlist(_at_)yourdomain
* $? test -s $AUTH_FILE
* $? echo $FROM | $FGREP -i -f $AUTH_FILE
{
# delivery
}
---
Please DO NOT carbon me on list replies. I'll get my copy from the list.
Sean B. Straw / Professional Software Engineering
Post Box 2395 / San Rafael, CA 94912-2395