Recipe 6.14 Enabling Spam Checks on a Per-User Basis

Recipe 6.14 Enabling Spam Checks on a Per- User Basis

Problem

You have been asked to create a sendmail configuration that applies checks only when the mail is addressed to selected recipients.

Solution

Add an entry to the /etc/mail/access text file for each recipient whose mail must pass all checks before it is delivered. Use the tag Spam : and the recipient address to create the key field of the entry. Use the keyword HATER as the return value for each entry. Run makemap to build a hash type database from the text file.

Create a sendmail configuration containing the access_db feature and the delay_checks feature with the optional hater argument. Make sure that the access_db FEATURE macro precedes the delay_checks FEATURE macro in the configuration. Here are the lines that would be added to the sendmail configuration:

 dnl Use the access database FEATURE(`access_db') dnl Apply all checks to spam hater mail FEATURE(`delay_checks', `hater') 

Rebuild the sendmail.cf file, copy the new sendmail.cf file to /etc/mail , and restart sendmail, as described in Recipe 1.8.

Discussion

The delay_checks feature changes the order in which checks are applied by first checking the envelope recipient address. When the delay_checks feature is invoked with the hater argument, as shown in the Solution section, the envelope recipient address must be found in the access database, and it must return the value HATER before the envelope sender address or the connection address are checked. If the envelope sender address is not found in the access database or does not return the value HATER , the check of the envelope sender address performed by check_mail , and the check of the connection address performed by check_relay , are bypassed.

To apply the check_mail and check_relay checks to a recipient's mail, the specific recipients must be defined in the access database using the Spam : tag and the HATER return value. Here are example entries:

 Connect:example.com                  REJECT Spam:jay@wrotethebook.com            HATER Spam:alana@wrotethebook.com          HATER 

Using this recipe's sendmail configuration, this access database will reject mail from example.com when it is addressed to jay@wrotethebook.com or to alana@wrotethebook.com . Other users are allowed to receive mail from example.com .

See Also

Recipe 6.13 provides a related example. Chapter 3 and Introduction to this chapter provide more information about the access database. The sendmail book covers the access database in Section 7.5 and the delay_checks feature in Section 7.5.6. The Delay all checks section of the cf/README file also covers this topic.



Sendmail Cookbook
sendmail Cookbook
ISBN: 0596004710
EAN: 2147483647
Year: 2005
Pages: 178
Authors: Craig Hunt

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net