Invoking DSPAM from Mailagent

Mailagent is a very flexible MDA, and as such, there are many approaches to integrating it with spam filters. For this "how-to", we tell mailagent to have dspam's command line utility add a header, and then filter on that header. For this to work, quarantining should be off. Your etc/dpsam.conf file should either retain the default option Preference "spamAction=tag", which will add "[SPAM]" to the header of all suspects, or set spamAction=deliver, which leaves the subject unmolested.

Edit your mailagent rules, and add the following:

{ FEED dspam --user %u --stdout --deliver=innocent,spam ;
  RESYNC;
  REJECT };

This asks dspam to filter all messages, and tells mailagent to then re-parse the headers from dspam's output. The REJECT is required, telling mailagent to continue matching.

If dspam is in your home directory or some other location not in the system path, you may need to add its complete path (eg /home/me/bin/dspam instead of dspam). You can also STRIP any headers you aren't interested in storing before the RESYNC.

From there, you can use mailagent's filters on the X-DSPAM-Result, X-DSPAM-Confidence, and X-DSPAM-Probability headers.

For the sake of simplicity, here's an example diverting spam to an mh-style folder, leaving other mail untouched. Make this the final lines of your mailagent rules, after the recently added FEED & RESYNC:

# divert spam
X-DSPAM-Result <-2,->: /Spam$/         { SAVE +spam };

# Default action
{ LEAVE };

You may also see "Innocent" or "Whitelisted" in X-DSPAM-Result. The <-2,-> tells Mailagent to use the last DSPAM header only, ingoring any spurious headers spammers may have added.

Replacing "SAVE +spam" with "MESSAGE /path/to/reply_msg;DELETE" would send a warning message from the file "reply_msg" to the sender of any message marked as spam, and discard the incoming message. This lets senders know about any false positives. It unfortunatele also has the side effect of sending your reply message to the frequently forged addresses in your spams' From/Reply-to headers.

Send yourself some mail, see that it works, check the mailagent log if it isn't all purring along smoothly as expected.

To tell dspam it's made a mistake, you have to tell your client to pipe the message in question to dspam --source=error --user $USER --class=spam|innocent, choosing either "spam" or "innocent" to tell dspam what that message actually was.

Now you can sit back and relax, back in the good old days of email, when biff(1) was useful...

last edited 2006-09-07 19:21:01 by LucianGray