2012-04-08 02:11:16 +02:00
|
|
|
#!perl -Tw
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
rcpt_ok
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
this plugin checks the standard rcpthosts config
|
|
|
|
|
|
|
|
It should be configured to be run _LAST_!
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
2006-01-25 03:59:31 +01:00
|
|
|
use Qpsmtpd::DSN;
|
2004-09-22 18:01:16 +02:00
|
|
|
|
2005-07-07 06:17:39 +02:00
|
|
|
sub hook_rcpt {
|
2006-04-07 20:58:02 +02:00
|
|
|
my ($self, $transaction, $recipient, %param) = @_;
|
2004-09-22 18:01:16 +02:00
|
|
|
my $host = lc $recipient->host;
|
|
|
|
|
|
|
|
my @rcpt_hosts = ($self->qp->config("me"), $self->qp->config("rcpthosts"));
|
|
|
|
|
|
|
|
# Allow 'no @' addresses for 'postmaster' and 'abuse'
|
|
|
|
# qmail-smtpd will do this for all users without a domain, but we'll
|
|
|
|
# be a bit more picky. Maybe that's a bad idea.
|
|
|
|
my $user = $recipient->user;
|
|
|
|
$host = $self->qp->config("me")
|
|
|
|
if ($host eq "" && (lc $user eq "postmaster" || lc $user eq "abuse"));
|
|
|
|
|
|
|
|
# Check if this recipient host is allowed
|
|
|
|
for my $allowed (@rcpt_hosts) {
|
|
|
|
$allowed =~ s/^\s*(\S+)/$1/;
|
|
|
|
return (OK) if $host eq lc $allowed;
|
|
|
|
return (OK) if substr($allowed,0,1) eq "." and $host =~ m/\Q$allowed\E$/i;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $more_rcpt_hosts = $self->qp->config('morercpthosts', 'map');
|
|
|
|
return (OK) if exists $more_rcpt_hosts->{$host};
|
|
|
|
|
|
|
|
if ( $self->qp->connection->relay_client ) { # failsafe
|
|
|
|
return (OK);
|
|
|
|
}
|
|
|
|
else {
|
2006-01-25 03:59:31 +01:00
|
|
|
# default of relaying_denied is obviously DENY,
|
|
|
|
# we use the default "Relaying denied" message...
|
|
|
|
return Qpsmtpd::DSN->relaying_denied();
|
2004-09-22 18:01:16 +02:00
|
|
|
}
|
|
|
|
}
|