--- ../Mail-SPF-Query-1.97/sample/sendmail-milter 2003-12-09 23:35:46.000000000 +0100 +++ sendmail-milter-spf-1.1.pl.ak.2 2004-01-10 12:27:40.000000000 +0100 @@ -1,3 +1,4 @@ +#!/usr/bin/perl # Sendmail Milter to perform SPF lookups # # Code by Mark Kramer on December 3, 2003 @@ -75,7 +76,7 @@ # usage: # socket_call (0) => undef # socket_call (1, sockaddr_in) - # socket_call (2, "1.2.3.4", 'sender(_at_)example(_dot_)com', 'helohostname.example.com') + # socket_call (2, "1.2.3.4", 'sender(_at_)example(_dot_)com', 'helohostname.example.com', 'me(_at_)mydomain(_dot_)com') my $choice = shift; @@ -105,7 +106,7 @@ my $priv_data = shift; if (my $query = eval {new Mail::SPF::Query (ip => shift, sender => shift, helo => shift)}) { my ($result, $smtp_comment, $header_comment); - if (eval {($result, $smtp_comment, $header_comment) = $query->result()}) { + if (eval {($result, $smtp_comment, $header_comment) = $query->result2(shift)}) { # Return $smtp_comment, if defined, else the prefab $header_comment. @@ -183,7 +184,23 @@ # Make the SPF query, and immediately store the result in our private hash; # we may also need it later, at eom_callback. - } elsif ($priv_data->{'spf_result'} = socket_call (2, $priv_data, $priv_data->{'ipaddr'}, $priv_data->{'from'}, $priv_data->{'helo'})) { + } + return SMFIS_CONTINUE; +} + +sub envrcpt_callback : locked { + my $ctx = shift; + my $priv_data = $ctx->getpriv(); + ($priv_data->{'to'} = lc (shift)) =~ s/[<>]//g; + + # envfrom_callback can be called more than once within the same connection; + # delete $priv_data->{'spf_result'} on entry! + + delete $priv_data->{'spf_result'}; + + $ctx->setpriv($priv_data); + + if ($priv_data->{'spf_result'} = socket_call (2, $priv_data, $priv_data->{'ipaddr'}, $priv_data->{'from'}, $priv_data->{'helo'}, $priv_data->{'to'})) { if ($priv_data->{'spf_result'} eq 'fail') { $ctx->setreply('550', '5.7.1', "[$priv_data->{'spf_smtp_comment'}]; see: http://spf.pobox.com/why.html?sender=$priv_data->{'from'}&ip=$priv_data->{'ipaddr'}"); return SMFIS_REJECT; @@ -224,6 +241,7 @@ 'connect' => \&connect_callback, 'helo' => \&helo_callback, 'envfrom' => \&envfrom_callback, + 'envrcpt' => \&envrcpt_callback, 'eom' => \&eom_callback, 'close' => \&close_callback, 'abort' => \&close_callback, ------- Sender Permitted From: http://spf.pobox.com/ Archives at http://archives.listbox.com/spf-discuss/current/ Latest draft at http://spf.pobox.com/draft-mengwong-spf-02.9.4.txt To unsubscribe, change your address, or temporarily deactivate your subscription, please go to http://v2.listbox.com/member/?listname(_at_)©#«Mo\¯HÝÜîU;±¤Ö¤Íµøˆ¡