[Mimedefang] SpamAssassin and SQL user preferences

Zach Lowry zach at zachlowry.net
Sun Sep 8 13:18:01 EDT 2002


 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've gotten some of this to work. Since I'm really lame at Perl, it's
probably horrible code, it was written by trial-and-error. This was
added into mimedefang-filter, right before 'if ($hits >= $req) {'.

            # SQL User Lookup Modified by Zach Lowry on 9/6/02
            my($hits, $req, $names, $report) = spam_assassin_check();
            my $dbuser = "spam";
            my $dbpass = "spam";
            use DBI;
            my $dbh = DBI->connect('DBI:mysql:spam:10.0.0.10',
$dbuser, $dbpass)
;
            my $recipient = $Recipients[0];
            $recipient =~ s/[<>]//g;
            $recipient =~ s/\@.*//;
            my $query = "SELECT value FROM userpref WHERE username =
'$recipient
' AND preference = 'required_hits'";
            my $sth = $dbh->prepare($query);
            $sth->execute();
            my $sqlvalue = $sth->fetchrow_arrayref;
            if ("@$sqlvalue" != "") {
                $req = "@$sqlvalue";
            }

Maybe this'll help someone else out. It only pulls the required
variable, obviously, that one is the major concern. Later, I'll
actually create a patch for mimedefag.pl to call spamassassin and get
the sql preferences, if they exist. 

Zach Lowry

-----BEGIN PGP SIGNATURE-----
Version: PGP 7.0.4

iQA/AwUBPXuGCYHWQmQc5olOEQJWagCcDpyX1U289vmPG3qtrnekXLvV1xsAniGe
i5JdM8BnGuML1MxkvbTfz4M/
=aBvh
-----END PGP SIGNATURE-----




More information about the MIMEDefang mailing list