# -*- cperl -*-
#
# Copyright (c) 2003  Robert James Kaes <rjkaes@flarenet.com>
#   All rights reserved.
#
# This plugin is released under the same license as Qpsmtpd itself.
#

sub register {
    my ($self, $qp) = @_;
    $self->register_hook("rcpt", "rblsmtpd");
}

sub rblsmtpd {
    my ($self, $transaction, $rcpt) = @_;

    return DECLINED unless defined $ENV{RBLSMTPD} and $ENV{RBLSMTPD} ne '';
    my $rblsmtpd = $ENV{RBLSMTPD};

    if (substr($rblsmtpd, 0, 1) eq '-') {
	return (DENY, substr($rblsmtpd, 1));
    } else {
	return (DENYSOFT, $rblsmtpd);
    }
}

__END__

=head1 NAME

rblsmtpd_env

=head1 DESCRIPTION

Checks for the C<RBLSMTPD> environment variable and responds as the
F<rblsmtpd> program would.

=head1 USAGE

Place this plugin B<before> any DNSBL plugins in F<config/plugins>.
The idea is to minimize the amount of network traffic and also the amount
of system resources used to process the message.  There is very little
point in querying a DNSBL when we know that the connection has been
refused locally.

=head1 HISTORY

=over

=item 1.2 - 2003-09-04

Removed the support for the F<config/rfcrequired> file since that is a
white-list concept that should be provided by a separate plugin called
B<before> any other plugin that could deny based on the C<MAIL FROM>
command.

=item 1.1 - 2003-08-29

Included support for the F<config/rfcrequired> file to allow mail to
RFC required users.

Also changed the hook to be on the rcpt.

=item 1.0 - 2003-08-28

The initial version that functioned like the rblsmtpd program.

=back

=head1 AUTHOR

Copyright (c) 2003  L<Robert James Kaes|mailto:rjkaes@flarenet.com>

=cut
