qpsmtpd/plugins/check_badrcptto
Ask Bjørn Hansen e9b02cb730 new plugins from Jim Winstead
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@63 958fd67b-6ff1-0310-b445-bb7760255be9
2002-09-10 11:00:31 +00:00

23 lines
708 B
Plaintext

# this plugin checks the badrcptto config (like badmailfrom for rcpt address)
sub register {
my ($self, $qp) = @_;
$self->register_hook("rcpt", "check_for_badrcptto");
}
sub check_for_badrcptto {
my ($self, $transaction, $recipient) = @_;
return (DECLINED) unless $recipient->host && $recipient->user;
my $host = lc $recipient->host;
my $from = $recipient->user . '@' . $host;
my @badrcptto = $self->qp->config("badrcptto");
for my $bad (@badrcptto) {
$bad =~ s/^\s*(\S+)/$1/;
return (DENY, "mail to $bad not accepted here")
if $bad eq $from;
return (DENY, "mail to $bad not accepted here")
if substr($bad,0,1) eq '@' && $bad eq "@$host";
}
return (DECLINED);
}