SPAMbaffle 4.0 Users Guide
SPAMbaffle Homepage| Features| System Requirements| Downloading & Registration| Installation| Configuration| Advanced Topics| Troubleshooting

SPAMbaffle 4.0 Advanced Configuration

Global setup
You can configure QMail to call SPAMbaffle for any user on your system who does not have a .qmail file by modifying your /var/qmail/rc file. For example, if the contents of your rc file are:

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start ./Maildir/ splogger qmail

you might change them to:

exec env - PATH="/var/qmail/bin:$PATH" \
qmail-start "|/usr/bin/SPAMbaffle.pl /.SPAMbaffle
./Maildir/" splogger qmail

NOTES:
  • Be sure to add a double quote character after "./Maildir/" (or ".Mailbox", or whatever your old default delivery instruction was).
  • Be sure to leave a line break before "./Maildir/". Do not end the previous line with a backslash.
  • This example assumes that SPAMbaffle.pl is installed in /usr/bin, and that you have a global filtering rules file named ".SPAMbaffle" in your global filtering rules directory.
  • If a user has their own .qmail file, this command will not be executed. If they wish to use the global filtering rules, they will need to add a line to their .qmail file to do that. Read below for more details.

Specifying filtering rules and log files
NOTE: Remember that files whose names start with a period are hidden by default, so you'll need to be set to list hidden files when you go looking for them. For example, the shell, use the command "ls -a" to list all files, including hidden files.

To do this: Do this:
Use a filtering rules file that isn't named ".SPAMbaffle" or is in a subfolder of your home directory

Edit the file in your home directory named ".qmail" or ".qmail-<alias name>". Add the name of your filtering rules file (in this example, ".myFilteringRules") after "SPAMbaffle.pl" so that SPAMbaffle's line looks similar to this:

|/usr/bin/SPAMbaffle.pl .myFilteringRules

You may also use this feature to tell SPAMbaffle to use the filtering rules file in your SPAMbaffle folder instead of in your home directory by specifying:

|/usr/bin/SPAMbaffle.pl SPAMbaffle/.SPAMbaffle

Note that while this is more convenient, since you do not need to copy and set the permissions on your filtering file whenever you modify it, this method is less secure, because on most web servers, it requires using a filtering rules file that could be modified by people other than yourself. Future versions of SPAMbaffle will attempt to address this issue.

Use a global (shared) filtering rules file

Edit the file in your home directory named ".qmail" or ".qmail-<alias name>". Add the name of the global filtering rules file (in this example, "globalRules"), preceded by a forward slash, after "SPAMbaffle.pl" so that SPAMbaffle's line looks similar to this:

|/usr/bin/SPAMbaffle.pl /globalRules

Use more than one filtering rules file

Edit the file in your home directory named ".qmail" or ".qmail-<alias name>". Duplicate the line that looks like this:

|/usr/bin/SPAMbaffle.pl

Then, add the name of your filtering rules file after "SPAMbaffle.pl" (in this example, ".myFilteringRules"--you could also use a global rules file as described above) so that the new line looks similar to this:

|/usr/bin/SPAMbaffle.pl .myFilteringRules

Use a different log file than the one named in the filtering rules file

Edit the file in your home directory named ".qmail" or ".qmail-<alias name>". Add the name of your filtering rules file (in this example, ".myFilteringRules") and log file ("MyLogFile" here) after "SPAMbaffle.pl" so that SPAMbaffle's line looks similar to the following. Note that to override the log file name, you must specify a filtering rules file name:

|/usr/bin/SPAMbaffle.pl .myFilteringRules MyLogFile

You may do the same when using global filtering rules as follows:

|/usr/bin/SPAMbaffle.pl /globalRules MyLogFile

Pattern matching syntax
SPAMbaffle uses "regular expressions" when comparing search patterns to the text in an email. This makes the matching far more flexible and powerful, but in some cases, a bit more complicated. Also, we have added a few exceptions to the normal rules of pattern matching to make emal filtering work more easily. Keep the following in mind when specifying your match patterns:

Issue: Details:
Case sensitivity Patterns matching in SPAMbaffle is not case sensitive. You may enter patterns in upper, lower, or mixed case.
Wildcard characters Periods acts as wildcards, matching any single character. To match an actual period, preceed the period with a backslash, like this: \. For example, to match "spam.com", but not "spamocom", enter: spam\.com
Checking for blank headers To search for a blank header (subject line, sender address, etc.), enter a single period on a line by itsself. This is a special exception to the rules of a period acting as a wildcard character.
Sets of characters

To match any one of a set of characters, enclose them all in square brackets ([]). For example, [0-9] would match any digit, [abx] would match an "a", a "b" or an "x", and [a-z0-9] would match any alphanumeric character.

To match any character not in a particular set, enter ^ immediately after the opening bracket. For example, [^a-z] would match any character that is not a letter.

Matching alternatives Use the "pipe" character (|) to specify alternative things to match. Usually, this is used with subexpressions, which are formed by enclosing part of your pattern in parenthesis. For example, "My name is (Joe|John)!" would match either "My name is Joe!" or "My name is John!".
Repetitions of characters and subexpressions

An asterisk indicates zero or more repetitions of the preceeding entity. For example, "a*" would match zero or more "a"s, "[a-z]*" would match zero or more letters, "(xo)*" would match zero or more repetitions of "xo", and "(jo|mo)*" would match zero or more repetitions of "jo" and/or "mo".

Similarly, a plus sign indicates 1 or more repetitions.

Numbers in braces indicate a specific number of repetitions. For example "!{4}" would match 4 exclamation points.

You can also match ranges of repetitions, for example "Say (hey,* ){3,5} dude!" would match "Say hey, hey, hey dude!", but not "Say hey, hey dude!"

Special characters

As you've seen above, there are various characters that have special meanings in patterns. To actually match these characters themselves, you must preceed them with a backslash. The list of characters that must be "escaped" with a backslash is:

.*+?[](){}:^$\|
Other Various other special sequences can be used to aid in your searching, some of which are:
  • \t - tab
  • \w - a "word" character ([a-z0-9_])
  • \W - a "non-word" character (the same as [^a-z0-9_])
  • \s - a whitespace character
  • \S - a non-whitespace character
  • \d - a digit ([0-9])
  • \D - a non-digit([^0-9])
  • \b - a word boundary