qpsmtpd/plugins/check_badrcptto
Ask Bjørn Hansen a23d4b3da9 Fix 01-syntax test failures
Exclude some tests with dependencies.

Remove -T from perl line in plugins
This makes it harder to test with PERL5LIB/perlbrew etc
2012-04-29 01:36:01 -07:00

23 lines
754 B
Perl

#!perl -w
# this plugin checks the badrcptto config (like badmailfrom, but for rcpt address
# rather than sender address)
use Qpsmtpd::DSN;
sub hook_rcpt {
my ($self, $transaction, $recipient, %param) = @_;
my @badrcptto = $self->qp->config("badrcptto") or return (DECLINED);
return (DECLINED) unless $recipient->host && $recipient->user;
my $host = lc $recipient->host;
my $to = lc($recipient->user) . '@' . $host;
for my $bad (@badrcptto) {
$bad = lc $bad;
$bad =~ s/^\s*(\S+)/$1/;
return Qpsmtpd::DSN->no_such_user("mail to $bad not accepted here")
if $bad eq $to;
return Qpsmtpd::DSN->no_such_user("mail to $bad not accepted here")
if substr($bad,0,1) eq '@' && $bad eq "\@$host";
}
return (DECLINED);
}