Introduction
MPNews includes a powerful automated filtering module to help you enforce the rules of your newsgroups. It can be a bit daunting to start setting up your own rules, so this article aims to take you through the basics.

Filters, Rules and Actions
A filter contains a set of one or more rules which each new message is tested against. If the message matches each of the rules, the actions associated with the filter are executed.

Normally the purpose of a filter is to reject unwanted messages. To do this, you must add any rules you need to define the messages you do not want.

For example, if you don't want messages with attachments, you would simply add a rule which matches messages with attachments. If you don't want messages with attachments in certain newsgroups, you would add another rule which matches messages posted to those newsgroups. By being able to combine any number of rules, your filters can be as precise or all-encompasing as you require.

Creating a filter
In this section, we will take you through the process of defining a filter that will stop people posting HTML formatted messages in a newsgroup called "mycompany.general". After going through this tutorial, you should be able to adapt the instructions to create any filter you require.

To create a new filter, log in to the main MPNews administration site, select the "Filtering" option, and click on the "Add New Filter" link. This will show you a screen with a blank filter.

The first thing to do is give your filter a useful name. This name is for your use only, and won't be displayed to any users. For our example, enter the name "No HTML in mycompany.general".

Now we need to add the rules which will form the core of this filter. Remember we need to add the rules which, when combined, define the messages we want to block. In this case we will require a rule which matches HTML formatted messages and another which matches messages posted to the "mycompany.general" newsgroup.

To add a rule, click on the "Add new rule" button. Select the "Limit articles with HTML formatting" rule, and click on Save to add it to the filter.

Click on "Add new rule" again to add another rule, and select the "Limit articles posted to specific newsgroups". For many types of rules, including this one, there are various options you can configure to change how the rule works. In this case, you can use these options to change which newsgroups the rule checks for. On our case, we want to change this to "mycompany.general" - do this now in the "Rule Options" section, then click on Save again to add it to the filter.

Your filter is now set up, and you will no longer be able to post HTML formatted messages to the "mycompany.general" newsgroup. Feel free to experiment with the other rule types in different combinations and see what properties each one lets you edit to change how they behave, and you should be able to come up with combinations which match just about anything you want.

So now we have a filter that rejects these messages, what next?

Filter actions
As mentioned earlier, when a message matches all the rules in a filter, the actions in that filter are executed. To change what actions those are, go to the "Actions" area in the filter screen.

By default, the action is set to "Reject the message with the error "This message is not allowed"". You can change this error message to provide a more useful hint to the user. For our example, you could change it to "HTML formatted messages are not allowed in this newsgroup - change your message to plain text and try again".

The "Reject the message" action will take care of about 99% of filters. However, in some cases you might want to do something more interesting instead, such as altering the message in some way or performing some other action.

A few other possible actions are provided with MPNews, including adding and deleting header values or adding a standard "tag" to the end of the message text. These can be added and customized in the same way as rules, by selecting the "Run custom actions" option then clicking on "Add new action" to select the type of action to add.

Custom rules and actions
You may have a situation where the rules or actions supplied with MPNews do not cover what you need. It is possible to write your own using a variety of scripting languages, or you can use our customization service and let us write one for you.