51486d0b04
added POD description of spfquery note changed spf_deny -> reject (and offered 4 more options, see POD for reject) backwards compatible with old config settings replicates qmail-smtpd SPF patch behavior improved logging (again) uses a stringy eval 'use Mail::SPF' in the register sub. If missing, warn and log the error, and don't register any hooks. This is much nicer error than the current, "*** Remote host closed connection unexpectedly." broken mail server that results from enabling the SPF plugin without Mail::SPF installed. background: I noticed I was deferring valid emails with the SPF plugin at 'spf_deny 1', and without changing the code, there wasn't a way to change how ~all records were handled. This provides that flexibility.
51 lines
1.3 KiB
Perl
51 lines
1.3 KiB
Perl
#!perl -w
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Qpsmtpd::Constants;
|
|
|
|
my $r;
|
|
|
|
sub register_tests {
|
|
my $self = shift;
|
|
|
|
eval 'use Mail::SPF';
|
|
return if $@;
|
|
|
|
$self->register_test('test_is_relayclient', 3);
|
|
$self->register_test('test_is_special_recipient', 5);
|
|
}
|
|
|
|
sub test_is_relayclient {
|
|
my $self = shift;
|
|
|
|
my $transaction = $self->qp->transaction;
|
|
ok( ! $self->is_relayclient( $transaction ),
|
|
"sender_permitted_from, is_relayclient -");
|
|
|
|
$self->qp->connection->relay_client(1);
|
|
ok( $self->is_relayclient( $transaction ),
|
|
"sender_permitted_from, is_relayclient +");
|
|
|
|
$self->qp->connection->relay_client(0);
|
|
$self->qp->connection->remote_ip('192.168.7.5');
|
|
my $client_ip = $self->qp->connection->remote_ip;
|
|
ok( $client_ip, "sender_permitted_from, relayclients ($client_ip)");
|
|
};
|
|
|
|
sub test_is_special_recipient {
|
|
my $self = shift;
|
|
|
|
my $transaction = $self->qp->transaction;
|
|
my $address = Qpsmtpd::Address->new('user@example.com');
|
|
|
|
ok( ! $self->is_special_recipient( $address ), "is_special_recipient -");
|
|
|
|
foreach my $user ( qw/ postmaster abuse mailer-daemon root / ) {
|
|
$address = Qpsmtpd::Address->new("$user\@example.com");
|
|
ok( $self->is_special_recipient( $address ), "is_special_recipient ($user)");
|
|
};
|
|
};
|
|
|