Sendmail::AccessDB - An interface to the Sendmail access.db list


 use Sendmail::AccessDB qw(spam_friend whitelisted);
 $friend_or_hater = spam_friend('');
 $whitelisted = whitelisted('');


This module is designed so that users of the Sendmail::Milter module (or other Sendmail programmers) can ascertain if a user has elected to whitelist themselves as a "spam friend" (where there should be no spam filtering on mail to them) or, where spam-filtering is not the default, but an option, where certain receipients have been labeled as "spam haters"


 use Sendmail::AccessDB qw(spam_friend);
 $friend_or_hater = spam_friend('');

Ordinarily, this will look for such things as "", "Spam:user@", etc., in the /etc/mail/access.db file. There is an optional second argument "Category", which could be used if you wanted to enable specific checks, for example, if you wanted to customize down to a per-check basis, you might use:

 $rbl_friend_or_hater = spam_friend('',
                                    'qualifier' => 'maps_rbl'); 
 $dul_friend_or_hater = spam_friend('',
                                    'qualifier' => 'maps_dul'); 

Caution should be taken when defining your own categories, as they may inadvertantly conflict with Sendmail-defined categories.

 use Sendmail::AccessDB qw(whitelisted);
 $whitelisted = whitelisted('');
 $whitelisted_host = whitelisted('');
 $whitelisted_addr = whitelisted('');

Would check for appropriate whitelisting entries in access.db. Some lookups might be ambiguous, for example:

 $whitelisted = whitelisted('foobar');

where it is hard to know if that is supposed to be a hostname, or a sender. whitelisted() accepts the 'type' argument, such as:

 $whitelisted = whitelisted('foobar','type'=>'hostname');
 $whitelisted = whitelisted('postmaster','type'=>'mail');

It's also possible to feed the qualifier argument, if necessary, for example, to do:

 $whitelisted = whitelisted('','type'=>'hostname',
                            'qualifier' => 'Connect');

which would check to see if this host has an OK flag set for the Connect qualifier.

There is also the generic "lookup", which, at its simplest, takes a single argument:

 $rc = lookup('');

will do a lookup on But if you wanted to pay attention to parent-domains, you might do:

 $rc = lookup('', 'type'=>'hostname');

but if you wanted to find out if '', or any of its parent domains ('' and 'com'), had a value in the "MyQual" qualifier, you might do:

 $rc = lookup('','type'=>'hostname','qualifier'=>'MyQual');

which would look up, in order '', '', and 'MyQual:com', returning the first (most specific) one found.


None that I've found yet, but I'm sure they're there.


Feel free to email me at <>


        Derek J. Balling
        CPAN ID: DREDD


Copyright (c) 2001 Derek J. Balling. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.




Each public function/method is described here. These are how you should interact with this module.


 Usage     : $friend_or_hater = spam_friend($recipient,
                                            ['qualifier' => $category])
 Purpose   : Consults the /etc/mail/access.db to check for spamfriendliness
 Returns   : 'FRIEND','HATER', or undef (which would mean default 
             behavior for that site)
 Argument  : The recipient e-mail address and an optional qualifier if
             the default of 'Spam' is not desired. 
 Throws    : 
 Comments  : 
 See Also  : 


 Usage     : whitelisted($value)
 Purpose   : Determine if an e-mail address, hostname, or IP address is
             explicitly whitelisted, in that it contains an "OK" or "RELAY"
             value in the database.
 Returns   : 0/1, true or false as to whether the argument is whitelisted
 Argument  : Either an email-address (e.g.,, an IP address
             (e.g.,, or a hostname (e.g.,
             as well as 'type' and 'qualifer' arguments (see lookup for greater
 Throws    : 
 Comments  : The code makes a pretty good attempt to figure out what type
             of argument $value is, but it can be overriden using the 'type'
See Also   : 


 Usage     : lookup ($lookup_key, 
                     'type'=>{'mail','ip','hostname'} ,   [optional]
                     'qualifier'=>'qualifier'             [optional]
                     'file'=>'filename'                   [optional]
 Purpose   : Do a generic lookup on a $lookup_key in the access.db and
             return the value found (or undef if not)
 Returns   : value in access.db or undef if not found
 Argument  : $lookup_key - mandatory. 'type'=>mail/ip/hostname will cause
             lookups against all necessary lookups according to sendmail logic
             (for things like hostname lookups where subdomains inherit 
             attributes of parent domains, etc.), 'qualifier'=>$q, where $q 
             will be preprended to the beginning of all lookups, (e.g., $q =
             'Spam', lookup would be against 'Spam:lookup_value')
 Throws    : 
 Comments  : If not using 'type', the 'qualifier' field can be mimicked by 
             simply looking for 'Qualifier:lookup'.
 See Also  : 


Each private function/method is described here. These methods and functions are considered private and are intended for internal use by this module. They are not considered part of the public interface and are described here for documentation purposes only.

_expand_ip, _expand_hostname, _expand_address

 Usage     : @expanded = _expand_ip($ip); # For example
 Returns   : Given an ip, hostname, or e-mail address, it will expand
             that into the "appropriate lookups" which sendmail would use
             (e.g., given '', _expand_ip would return
   , 192.168.1, 192.168, and 192)
 Argument  : The IP Address, hostname, or e-mail address to expand
 Throws    : 
 Comments  : 
 See Also  :