[Mimedefang] How can mimedefang use spamc/spamd funcitons of spamassassin?

John Nemeth jnemeth at victoria.tc.ca
Tue Apr 12 17:22:05 EDT 2005


On Sep 2,  6:37am, "Keith Patton" wrote:
} 
}  I need to create a per user set of rules for spamassassin. I see where 
} spamassassin supports it with ldap or sql, however it only appears to 
} work using the spamc/spamd pair not spamassasin -t..

     No, it works fine with the Mail::SpamAssassin modules.

} The best I can figure out is that mimedefang is using spamassassin -t 
} and not spamc/spamd.

     No, it directly uses the Mail::SpamAssassin modules.

} Is there anyone out here that has accomplished getting it to use 
} spamc/spamd?  or does anyone have any ideas on how to accomplish with 
} the least amount of effort?

     I store SpamAssassin preferences in a MySQL database.  I use
MIMEDefang's stream_by_recipient() to split up multi-recipient messages.
Then I simply do:

$SASpamTester->load_scoreonly_sql($user);

prior to:

my($hits, $req, $names, $report) = spam_assassin_check();

$user is found using this function (is_local_virtual() determines if
the domain is one that is handled by virtusertable, and is
is_local_alias() determines if the domain is considered to be
equivalent to the primary hostname; they do this by checking a list of
domains which is initialised in filter_initialize by reading them from
a file):

sub should_check_for_spam ($) {
    my($recip) = @_;
    my($value) = undef;
    $recip =~ tr/<>//d;
    $user = $recip;
    $user =~ s/(^.*)\@.*/$1/;
    $domain = lc $recip;
    $domain =~ s/.*\@(.*$)/$1/;
    $fulladdr = $user . '@' . $domain;

    if (is_local_virtual($domain)) {
        $dbh = get_db_connection();
        $quoteduser = $dbh->quote($fulladdr);
        $sth = $dbh->prepare(qq{SELECT value FROM userpref WHERE username = $quo
teduser && preference = 'checkspam'});
        $sth->execute();
        $value = $sth->fetchrow_array();
        $sth->finish();
        if (!defined($value) || $value ne "no") {
            return $fulladdr;
        }
    }

    if (is_local_alias($domain)) {
        $dbh = get_db_connection();
        $quoteduser = $dbh->quote($user);
        $sth = $dbh->prepare(qq{SELECT value FROM userpref WHERE username = $quo
teduser && preference = 'checkspam'});
        $sth->execute();
        $value = $sth->fetchrow_array();
        $sth->finish();
        if (!defined($value) || $value ne "no") {
            return $user;
        }
    }

    return undef;
}

}-- End of excerpt from "Keith Patton"



More information about the MIMEDefang mailing list