e9b02cb730
git-svn-id: https://svn.perl.org/qpsmtpd/trunk@63 958fd67b-6ff1-0310-b445-bb7760255be9
30 lines
863 B
Plaintext
30 lines
863 B
Plaintext
# this plugin checks the standard badmailfrom config
|
|
|
|
sub register {
|
|
my ($self, $qp) = @_;
|
|
$self->register_hook("mail", "mail_handler");
|
|
$self->register_hook("rcpt", "rcpt_handler");
|
|
}
|
|
|
|
sub mail_handler {
|
|
my ($self, $transaction, $recipient) = @_;
|
|
return (DECLINED) unless $recipient->host && $recipient->user;
|
|
my $host = lc $recipient->host;
|
|
my $from = $recipient->user . '@' . $host;
|
|
my @badmailfrom = $self->qp->config("badmailfrom");
|
|
for my $bad (@badmailfrom) {
|
|
$bad =~ s/^\s*(\S+)/$1/;
|
|
$transaction->notes('badmailfrom', "Mail from $bad not accepted here")
|
|
if ($bad eq $from)
|
|
|| (substr($bad,0,1) eq '@' && $bad eq "\@$host");
|
|
}
|
|
return (DECLINED);
|
|
}
|
|
|
|
sub rcpt_handler {
|
|
my ($self, $transaction, $rcpt) = @_;
|
|
my $note = $transaction->notes('badmailfrom');
|
|
return (DENY, $note) if $note;
|
|
return (DECLINED);
|
|
}
|