[Mimedefang] SpamAssassin and SQL user preferences

Aaron Paetznick aaronp at critd.com
Sun Sep 8 17:29:00 EDT 2002


That's one way to do it, but you're creating a whole new DB connection 
for each individual email, which is extremely inefficient.  David, what 
if we provided native, persistant facilities from the multiplexor?  That
would be far better, IMHO.

SpamAssassin does have built-in hooks for database preferences, but 
providing this functionality from within MIMEDefang would be far more 
elegant, also IMHO.


--Aaron



Zach Lowry wrote:
>  
> -----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-----
> 
> _______________________________________________
> MIMEDefang mailing list
> MIMEDefang at lists.roaringpenguin.com
> http://lists.roaringpenguin.com/mailman/listinfo/mimedefang





More information about the MIMEDefang mailing list