Web linux-server.50webs.com

Linux Mail Server

Filtering Out Spam at the Mailer (Part 2):

To process mail through the filter program, put the following line in .forward:

| "exec filter –o ~/filter.errors"

This assumes that you downloaded the filter source code, compiled it, and installed the executable in the smrsh execution directory. Most Linux systems, Red Hat included, use smrsh as the prog mailer. When mail is forwarded to a program, as it is in this example, it is handled by the prog mailer (which, in this case, is smrsh). smrsh will execute only programs found in its execution directory. In our sample Red Hat system, that directory is /etc/smrsh.

The filter program reads its configuration from the filter-rules file in the .elm directory in the user's home directory. Therefore, if the home directory of the user running filter is /home/sara, filter looks for a file named /home/sara/.elm/filter-rules. If the user doesn't really run elm, she needs to create an .elm directory to hold the configuration file.

The filter-rules file contains the directions for filtering the mail. It is written as a series of "if" statements. If the incoming mail matches the condition defined by the statement, it is processed in the manner that the statement directs. A sample filter-rules file illustrates how this works:

if (from = "*.gov") then Save ~/Mail/clients
if (from = "neil@sybex.com") then Save ~/Mail/editors
if (from = "kylie@sybex.com") then Save ~/Mail/editors
if (from = "*.wespamu.com") then Delete

This set of filters routes the mail received from different sources to different mailboxes. Mail from government consulting clients is routed to the clients mailbox; mail from Sybex editors is routed to the editors mailbox. The first three rules route mail to different mailboxes. The last rule discards unwanted mail; everything from wespamu.com is deleted.

Next: Filtering Out Spam at the Mailer (Part 3)

.