diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index df7a7f0..602aa93 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -31,6 +31,12 @@ sub recipients { ($self->{_recipients} ? @{$self->{_recipients}} : ()); } +sub relaying { + my $self = shift; + @_ and $self->{_relaying} = shift; + $self->{_relaying}; +} + sub sender { my $self = shift; @_ and $self->{_sender} = shift; @@ -112,7 +118,6 @@ sub body_getline { $self->{_body_file_writing} = 0; my $line = $self->{_body_file}->getline; return $line; - } sub DESTROY { @@ -164,6 +169,11 @@ This returns a list of the current recipients in the envelope. Each recipient returned is a C object. +=head2 relaying( ) + +Returns true if this mail transaction is relaying. This value is set +by the C plugin. + =head2 sender( [ ADDRESS ] ) Get or set the sender (MAIL FROM) address in the envelope. diff --git a/plugins/check_relay b/plugins/check_relay index db9c1cb..e2e19ca 100644 --- a/plugins/check_relay +++ b/plugins/check_relay @@ -23,14 +23,18 @@ sub check_relay { if ($host eq "" && (lc $user eq "postmaster" || lc $user eq "abuse")); # Check if this IP is allowed to relay - return (OK) if exists $ENV{RELAYCLIENT}; my @relay_clients = $self->qp->config("relayclients"); my $more_relay_clients = $self->qp->config("morerelayclients", "map"); my %relay_clients = map { $_ => 1 } @relay_clients; my $client_ip = $self->qp->connection->remote_ip; while ($client_ip) { - return (OK) if exists $relay_clients{$client_ip}; - return (OK) if exists $more_relay_clients->{$client_ip}; + if (exists($ENV{RELAYCLIENT}) or + exists($relay_clients{$client_ip}) or + exists($more_relay_clients->{$client_ip})) + { + $transaction->relaying(1); + return (OK); + } $client_ip =~ s/\d+\.?$//; # strip off another 8 bits }