add pod documentation and sanity checking of the config

git-svn-id: https://svn.perl.org/qpsmtpd/trunk@170 958fd67b-6ff1-0310-b445-bb7760255be9
This commit is contained in:
Ask Bjørn Hansen 2003-08-31 08:24:06 +00:00
parent e006f74d23
commit cb49a9079e

View File

@ -1,4 +1,18 @@
# this plugin checks the standard badmailfrom config =head1 NAME
check_badmailfrom - checks the standard badmailfrom config
=head1 DESCRIPTION
Reads the "badmailfrom" configuration like qmail-smtpd does. From the
qmail-smtpd docs:
"Unacceptable envelope sender addresses. qmail-smtpd will reject every
recipient address for a message if the envelope sender address is
listed in badmailfrom. A line in badmailfrom may be of the form
@host, meaning every address at host."
=cut
sub register { sub register {
my ($self, $qp) = @_; my ($self, $qp) = @_;
@ -8,6 +22,7 @@ sub register {
sub mail_handler { sub mail_handler {
my ($self, $transaction, $sender) = @_; my ($self, $transaction, $sender) = @_;
my @badmailfrom = $self->qp->config("badmailfrom") my @badmailfrom = $self->qp->config("badmailfrom")
or return (DECLINED); or return (DECLINED);
@ -18,7 +33,9 @@ sub mail_handler {
my $from = $sender->user . '@' . $host; my $from = $sender->user . '@' . $host;
for my $bad (@badmailfrom) { for my $bad (@badmailfrom) {
$bad =~ s/^\s*(\S+)/$1/; $bad =~ s/^\s*(\S+).*/$1/;
next unless $bad;
warn "Bad badmailfrom config: No \@ sign in $bad\n" and next unless $bad =~ m/\@/;
$transaction->notes('badmailfrom', "Mail from $bad not accepted here") $transaction->notes('badmailfrom', "Mail from $bad not accepted here")
if ($bad eq $from) if ($bad eq $from)
|| (substr($bad,0,1) eq '@' && $bad eq "\@$host"); || (substr($bad,0,1) eq '@' && $bad eq "\@$host");