I have the following combination of scripts *actually working*! (Joy!...):
#### Testing: invoke perl script and see if it passes back a recipe variable
####
:0
* ^From(_dot_)me(_at_)mydomain(_dot_)com
{
ADDRESS=`formail -rzx "To:"`
SQLRESULT=`$HOME/spamcheck.pl`
:0 :
testingFolder
}
#! /usr/bin/perl
# spamcheck.pl - queries 4procmail.spammers for address received as an
# argument
use strict;
use DBI;
# declare variables: $dbh as an instance of the DBI object,
# $sth is our query object, $result receives the query result.
# $ADDRESS gets the environment variable set by procmail
my ($dbh, $sth, $result, $ADDRESS);
$dbh = DBI->connect ("DBI:mysql:host=localhost;database=4procmail",
"username","password",
{PrintError => 0, RaiseError => 1});
$ADDRESS = $ENV{'ADDRESS'};
$sth = $dbh->prepare ("SELECT address FROM spammers WHERE address LIKE
'$ADDRESS'");
$sth->execute();
$result = $sth->rows();
print $result;
Procmail successfully receives the value of $result (the number of rows in the
returned query result) into its SQLRESULT variable, as shown by the log entry
below:
procmail: Match on "^From(_dot_)me(_at_)mydomain(_dot_)com"
procmail: Executing "formail,-rzx,To:"
procmail: [8490] Tue Dec 30 18:00:24 2003
procmail: Assigning "ADDRESS=me(_at_)mydomain(_dot_)com"
procmail: Executing "/home/user/spamcheck.pl"
procmail: [8490] Tue Dec 30 18:00:25 2003
procmail: Assigning "SQLRESULT=0"
Now, I want to do things in my recipe depending on the value of SQLRESULT.
procmail does not do conventional if() statements (right?), so how do I check
the value of SQLRESULT?
This amateur thanks you! :-)
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail