Blocking Spam - The access File

The access file offers you the ability to block incoming Email messages based on the Email address or sending domain of the incoming message. Some specific options you can chose include the following.

There are also a number of other features of the access file, which are documented in the /etc/mail/README file.

The access file settings are already built in to your VPS sendmail configuration. In order to use them, however, you must first create an access.db file in your /etc/mail directory.

The first step in creating your access.db file is to create a plain-text file in your /etc/mail directory named access. This should contain the domain or email account you want to base the filtering on, with a rule. Detailed instructions for using the access file are included in the /etc/mail/README file, but a few of the more common rules are listed here.

OK

Accept mail even if other rules in the running rule set would reject it, for example, if the domain name can not be resolved. "Accept" does not mean "relay", but at most acceptance for local recipients. That is, OK allows less than RELAY.

RELAY

Accept mail addressed to the indicated domain or received from the indicated domain for relaying through your SMTP server. RELAY also serves as an implicit OK for the other checks.

REJECT

Reject the sender or recipient with a general purpose message.

ERROR:### "any text"

the Error number should be an RFC 821 compliant error code, and "any text" is a message to return for the command. The string should be quoted to avoid surprises, e.g., sendmail may remove spaces otherwise.

The following is an example of a few different possible entries you could have in your access file.

cyberspammer.com        ERROR:550 "We don't accept mail from spammers"
okay.cyberspammer.com   OK
sendmail.org            RELAY
128.32                  RELAY
IPv6:1:2:3:4:5:6:7      RELAY
[127.0.0.3]             OK
[IPv6:1:2:3:4:5:6:7:8]  OK

After you have created your /etc/mail/access file, you must convert it into a .db file which sendmail can read. To do this, run the following command (as root) on your VPS v2

# makemap hash /etc/mail/access < /etc/mail/access