[Mimedefang] Spamassassin 3.0 + MD 2.42
Nelson1 at cog7.org
Nelson1 at cog7.org
Tue May 11 11:48:00 EDT 2004
Here is SPF check I am using in mimedefang-filter. Was thinking of moving
to filter_begin so action_add_header would work. Logging SPF info to
/etc/mail/spflist (amazing how many non-spammers send us e-mail as
ourselves). Also sendmail had trouble returning the "%40" in $smtp_comment
so removed that...
#Must enable SENDER_CHECK in /etc/init.d/sendmail
sub filter_sender {
my($sender, $ip, $hostname, $helo) = @_;
use Mail::SPF::Query;
my $query = new Mail::SPF::Query (ip => $ip, sender=>$sender,
helo=>$helo, trusted=>1, guess=>0);
my ($result, # pass | fail | softfail | neutral | none | error
| unknown [mechanism]
$smtp_comment, # "please see http://spf.pobox.com/why.html?..."
when rejecting, return this string to the SMTP client
$header_comment, # prepend_header("Received-SPF" => "$result
($header_comment)")
$spf_record, # "v=spf1 ..." original SPF record for the domain
) = $query->result();
#action_add_header('Received-SPF', "$result ($header_comment)");
if ($result ne "none") {
open(SPF, ">>/etc/mail/spflist");
print SPF "$result $ip $sender $helo $spf_record\n";
close(SPF);
}
$from = $sender;
$from =~ s/[<>]//g;
#$from =~ s/@/%40/g;
if ($result eq "pass") { return (CONTINUE,"ok"); }
elsif ($result eq "fail") { return (REJECT,"Sorry $sender not permitted,
please see http://spf.pobox.com/why.html?sender=$from&ip=$ip "); }
return (CONTINUE,"ok");
}
More information about the MIMEDefang
mailing list