# vim: se ft=perl : =pod =head1 SYNOPSIS A flexible way to check "RCPT TO:" addresses. =head1 CONFIG config/check_rcptto This file is perl code defining a reference to a list of subroutine references that should return a standard hook pair of a return code (DECLINED, DENYSOFT, etc.) plus return string, or no value (which means try the next function if there is one). The lowercased "RCPT TO" value is in $_ for your convenience. A silly example (don't really use these): [ sub { (my $login = (split /\@/)[0]) =~ s/\-.+$//; return undef if getpwnam($login); return (DENY, "Sorry, no mailbox for '$login'"); }, sub { /\d/ && return (DENY, 'Sorry, no digits allowed!') }, sub { (rand < 0.5) && return (DENYSOFT, 'Tails you lose!') }, ] =head1 AUTHOR Copyright 2005 Daniel Rench This software is free software and may be distributed under the same terms as Perl itself. =cut sub hook_rcpt { my ($self, $transaction, $recipient) = @_; my $functions = do $self->qp->config_dir('check_rcptto').'/check_rcptto'; return DECLINED unless defined $functions && UNIVERSAL::isa($functions, 'ARRAY'); local $_ = lc($recipient->user) . '@' . lc($recipient->host); foreach my $f (@$functions) { next unless UNIVERSAL::isa($f, 'CODE'); my @r = $f->(); return @r if $r[0]; } return DECLINED; }