Robin Bowes said the following on 10/01/2006 16:33:
> Here's what I'm currently using:
>
> # map to cdb file containing valid local email addresses
> my $validrcptto = $self->qp->config( 'validrcptto', 'map' )
> || return DECLINED;
>
> # build addresses to check:
> my $host = '@' . lc( $recipient->host );
> my ($user) = split $SEPARATOR, $recipient->user;
> my $to = lc($user) . $host;
>
> warn "$to not found in validrcptto"
> if (! exists $validrcptto->{$to} );
> warn "$host not found in validrcptto"
> if (! exists $validrcptto->{$host} );
>
> This produces the following in the log file:
>
> [EMAIL PROTECTED] not found in validrcptto at
> ./plugins/check_validrcptto_cdb line 54, <STDIN> line 173.
> @robinbowes.com not found in validrcptto at
> ./plugins/check_validrcptto_cdb line 56, <STDIN> line 173.
>
> I've added a "warn Dumper $validrcptto" which produces the following in
> the log:
>
> 2006-01-10 16:34:11.612815500 $VAR1 = {};
>
> So, it looks like the cdb is not getting read.
>
> This is the cdb file in th config dir:
>
> -rw-r--r-- 1 root root 4013 Jan 10 16:23 validrcptto.cdb
I've reverted to my original code and it's working OK again.
This is what works:
# cdb file containing valid local email addresses
my $validrcptto_file = 'config/validrcptto.cdb';
# don't check if file not readable
return (DECLINED) if ( ! -f $validrcptto_file );
# Open the cdb file and tie to hash
tie my %validrcptto, 'CDB_File', $validrcptto_file or
return (DECLINED);
# build addresses to check:
my $host = '@' . lc( $recipient->host );
my ($user) = split $SEPARATOR, $recipient->user;
my $to = lc($user) . $host;
warn "$to not found in validrcptto"
if (! exists $validrcptto{$to} );
warn "$host not found in validrcptto"
if (! exists $validrcptto{$host} );
warn Dumper %validrcptto;
# check for addresses in cdb file
if ( !( ( exists $validrcptto{$to} ) || ( exists $validrcptto{$host} ) )
)
{
# return ( DENY, "Sorry, there is no mailbox for $recipient here." );
}
Notice the commented out DENY line :)
This produces the following the logs:
2006-01-10 16:45:30.682571500 [EMAIL PROTECTED] not found in
validrcptto at ./plugins/check_validrcptto_cdb line 64, <STDIN> line 190.
2006-01-10 16:45:30.682588500 $VAR1 = '[EMAIL PROTECTED]';
2006-01-10 16:45:30.682593500 $VAR2 = '';
<snip>
2006-01-10 16:45:30.683092500 $VAR73 = '@robinbowes.com';
2006-01-10 16:45:30.683098500 $VAR74 = '';
i.e. the hash is getting populated OK.
Any ideas why the "clever" way doesn't work?
Thanks,
R.
--
http://robinbowes.com
If a man speaks in a forest,
and his wife's not there,
is he still wrong?