2003-04-25 05:52:00 +00:00
|
|
|
|
;;; mh-junk.el --- Interface to anti-spam measures
|
|
|
|
|
|
2005-10-10 16:37:54 +00:00
|
|
|
|
;; Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Satyaki Das <satyaki@theforce.stanford.edu>,
|
|
|
|
|
;; Bill Wohler <wohler@newt.com>
|
|
|
|
|
;; Maintainer: Bill Wohler <wohler@newt.com>
|
|
|
|
|
;; Keywords: mail, spam
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
|
;; any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
2005-07-04 17:55:18 +00:00
|
|
|
|
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
;; Boston, MA 02110-1301, USA.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; Spam handling in MH-E.
|
|
|
|
|
|
|
|
|
|
;;; Change Log:
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(eval-when-compile (require 'mh-acros))
|
|
|
|
|
(mh-require-cl)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(require 'mh-e)
|
|
|
|
|
|
|
|
|
|
;; Interactive functions callable from the folder buffer
|
|
|
|
|
;;;###mh-autoload
|
2004-07-13 03:06:25 +00:00
|
|
|
|
(defun mh-junk-blacklist (range)
|
|
|
|
|
"Blacklist RANGE as spam.
|
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
This command trains the spam program in use (see the `mh-junk-program' option)
|
|
|
|
|
with the content of the range (see `mh-interactive-range') and then handles
|
|
|
|
|
the message(s) as specified by the `mh-junk-disposition' option.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
For more information about using your particular spam fighting program, see:
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
- `mh-spamassassin-blacklist'
|
2003-04-25 05:52:00 +00:00
|
|
|
|
- `mh-bogofilter-blacklist'
|
2004-08-15 22:00:06 +00:00
|
|
|
|
- `mh-spamprobe-blacklist'"
|
2004-07-13 03:06:25 +00:00
|
|
|
|
(interactive (list (mh-interactive-range "Blacklist")))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(let ((blacklist-func (nth 1 (assoc mh-junk-choice mh-junk-function-alist))))
|
|
|
|
|
(unless blacklist-func
|
|
|
|
|
(error "Customize `mh-junk-program' appropriately"))
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(let ((dest (cond ((null mh-junk-disposition) nil)
|
|
|
|
|
((equal mh-junk-disposition "") "+")
|
|
|
|
|
((eq (aref mh-junk-disposition 0) ?+)
|
|
|
|
|
mh-junk-disposition)
|
|
|
|
|
((eq (aref mh-junk-disposition 0) ?@)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(concat mh-current-folder "/"
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(substring mh-junk-disposition 1)))
|
|
|
|
|
(t (concat "+" mh-junk-disposition)))))
|
2004-07-13 03:06:25 +00:00
|
|
|
|
(mh-iterate-on-range msg range
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Blacklisting message %d..." msg)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(funcall (symbol-function blacklist-func) msg)
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Blacklisting message %d...done" msg)
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(if (not (memq msg mh-seen-list))
|
|
|
|
|
(setq mh-seen-list (cons msg mh-seen-list)))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(if dest
|
|
|
|
|
(mh-refile-a-msg nil (intern dest))
|
|
|
|
|
(mh-delete-a-msg nil)))
|
|
|
|
|
(mh-next-msg))))
|
|
|
|
|
|
|
|
|
|
;;;###mh-autoload
|
2004-07-13 03:06:25 +00:00
|
|
|
|
(defun mh-junk-whitelist (range)
|
2004-08-15 22:00:06 +00:00
|
|
|
|
"Whitelist RANGE as ham.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
This command reclassifies a range of messages (see `mh-interactive-range') as
|
|
|
|
|
ham if it were incorrectly classified as spam. It then refiles the message
|
|
|
|
|
into the `+inbox' folder.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
The `mh-junk-program' option specifies the spam program in use."
|
2004-07-13 03:06:25 +00:00
|
|
|
|
(interactive (list (mh-interactive-range "Whitelist")))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(let ((whitelist-func (nth 2 (assoc mh-junk-choice mh-junk-function-alist))))
|
|
|
|
|
(unless whitelist-func
|
|
|
|
|
(error "Customize `mh-junk-program' appropriately"))
|
2004-07-13 03:06:25 +00:00
|
|
|
|
(mh-iterate-on-range msg range
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Whitelisting message %d..." msg)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(funcall (symbol-function whitelist-func) msg)
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Whitelisting message %d...done" msg)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(mh-refile-a-msg nil (intern mh-inbox)))
|
|
|
|
|
(mh-next-msg)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
;; Spamassassin Interface
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(defvar mh-spamassassin-executable (executable-find "spamassassin"))
|
|
|
|
|
(defvar mh-sa-learn-executable (executable-find "sa-learn"))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(defun mh-spamassassin-blacklist (msg)
|
|
|
|
|
"Blacklist MSG with SpamAssassin.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
SpamAssassin is one of the more popular spam filtering programs. Get it from
|
|
|
|
|
your local distribution or from http://spamassassin.org/.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
To use SpamAssassin, add the following recipes to `.procmailrc':
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
MAILDIR=$HOME/`mhparam Path`
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
# Fight spam with SpamAssassin.
|
|
|
|
|
:0fw
|
|
|
|
|
| spamc
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
# Anything with a spam level of 10 or more is junked immediately.
|
|
|
|
|
:0:
|
|
|
|
|
* ^X-Spam-Level: ..........
|
|
|
|
|
/dev/null
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
:0:
|
|
|
|
|
* ^X-Spam-Status: Yes
|
|
|
|
|
spam/.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
If you don't use `spamc', use `spamassassin -P -a'.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
Note that one of the recipes above throws away messages with a score greater
|
|
|
|
|
than or equal to 10. Here's how you can determine a value that works best for
|
|
|
|
|
you.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
First, run `spamassassin -t' on every mail message in your archive and use
|
|
|
|
|
Gnumeric to verify that the average plus the standard deviation of good mail
|
|
|
|
|
is under 5, the SpamAssassin default for \"spam\".
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
Using Gnumeric, sort the messages by score and view the messages with the
|
|
|
|
|
highest score. Determine the score which encompasses all of your interesting
|
|
|
|
|
messages and add a couple of points to be conservative. Add that many dots to
|
|
|
|
|
the `X-Spam-Level:' header field above to send messages with that score down
|
|
|
|
|
the drain.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
In the example above, messages with a score of 5-9 are set aside in the
|
|
|
|
|
`+spam' folder for later review. The major weakness of rules-based filters is
|
|
|
|
|
a plethora of false positives so it is worthwhile to check.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
If SpamAssassin classifies a message incorrectly, or is unsure, you can use
|
|
|
|
|
the MH-E commands \\[mh-junk-blacklist] and \\[mh-junk-whitelist].
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
The \\[mh-junk-blacklist] command adds a `blacklist_from' entry to
|
|
|
|
|
`~/spamassassin/user_prefs', deletes the message, and sends the message to the
|
|
|
|
|
Razor, so that others might not see this spam. If the `sa-learn' command is
|
|
|
|
|
available, the message is also recategorized as spam.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
The \\[mh-junk-whitelist] command adds a `whitelist_from' rule to the
|
|
|
|
|
`~/.spamassassin/user_prefs' file. If the `sa-learn' command is available, the
|
|
|
|
|
message is also recategorized as ham.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
Over time, you'll observe that the same host or domain occurs repeatedly in
|
|
|
|
|
the `blacklist_from' entries, so you might think that you could avoid future
|
|
|
|
|
spam by blacklisting all mail from a particular domain. The utility function
|
|
|
|
|
`mh-spamassassin-identify-spammers' helps you do precisely that. This function
|
|
|
|
|
displays a frequency count of the hosts and domains in the `blacklist_from'
|
|
|
|
|
entries from the last blank line in `~/.spamassassin/user_prefs' to the end of
|
|
|
|
|
the file. This information can be used so that you can replace multiple
|
|
|
|
|
`blacklist_from' entries with a single wildcard entry such as:
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
blacklist_from *@*amazingoffersdirect2u.com
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
In versions of SpamAssassin (2.50 and on) that support a Bayesian classifier,
|
|
|
|
|
\\[mh-junk-blacklist] uses the `sa-learn' program to recategorize the message
|
|
|
|
|
as spam. Neither MH-E, nor SpamAssassin, rebuilds the database after adding
|
|
|
|
|
words, so you will need to run `sa-learn --rebuild' periodically. This can be
|
|
|
|
|
done by adding the following to your crontab:
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
0 * * * * sa-learn --rebuild > /dev/null 2>&1"
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(unless mh-spamassassin-executable
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(error "Unable to find the spamassassin executable"))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(let ((current-folder mh-current-folder)
|
|
|
|
|
(msg-file (mh-msg-filename msg mh-current-folder))
|
|
|
|
|
(sender))
|
|
|
|
|
(save-excursion
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Reporting message %d..." msg)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(mh-truncate-log-buffer)
|
|
|
|
|
(call-process mh-spamassassin-executable msg-file mh-log-buffer nil
|
2004-08-15 22:00:06 +00:00
|
|
|
|
;;"--report" "--remove-from-whitelist"
|
|
|
|
|
"-r" "-R") ; spamassassin V2.20
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(when mh-sa-learn-executable
|
|
|
|
|
(message "Recategorizing this message as spam...")
|
|
|
|
|
(call-process mh-sa-learn-executable msg-file mh-log-buffer nil
|
2004-07-13 03:06:25 +00:00
|
|
|
|
"--single" "--spam" "--local" "--no-rebuild"))
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Blacklisting message %d..." msg)
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(set-buffer (get-buffer-create mh-temp-buffer))
|
|
|
|
|
(erase-buffer)
|
2005-05-28 22:04:54 +00:00
|
|
|
|
(call-process (expand-file-name mh-scan-prog mh-progs)
|
|
|
|
|
nil mh-junk-background nil
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(format "%s" msg) current-folder
|
|
|
|
|
"-format" "%<(mymbox{from})%|%(addr{from})%>")
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(if (search-forward-regexp "^\\(.+\\)$" nil t)
|
|
|
|
|
(progn
|
|
|
|
|
(setq sender (match-string 0))
|
|
|
|
|
(mh-spamassassin-add-rule "blacklist_from" sender)
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Blacklisting message %d...done" msg))
|
|
|
|
|
(message "Blacklisting message %d...not done (from my address)" msg)))))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
|
|
|
|
(defun mh-spamassassin-whitelist (msg)
|
2004-08-15 22:00:06 +00:00
|
|
|
|
"Whitelist MSG with SpamAssassin.
|
|
|
|
|
|
|
|
|
|
The \\[mh-junk-whitelist] command adds a `whitelist_from' rule to the
|
|
|
|
|
`~/.spamassassin/user_prefs' file. If the `sa-learn' command is available, the
|
|
|
|
|
message is also recategorized as ham.
|
|
|
|
|
|
|
|
|
|
See `mh-spamassassin-blacklist' for more information."
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(unless mh-spamassassin-executable
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(error "Unable to find the spamassassin executable"))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(let ((msg-file (mh-msg-filename msg mh-current-folder))
|
|
|
|
|
(show-buffer (get-buffer mh-show-buffer))
|
|
|
|
|
from)
|
|
|
|
|
(save-excursion
|
|
|
|
|
(set-buffer (get-buffer-create mh-temp-buffer))
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(message "Removing spamassassin markup from message...")
|
|
|
|
|
(call-process mh-spamassassin-executable msg-file mh-temp-buffer nil
|
2004-08-15 22:00:06 +00:00
|
|
|
|
;; "--remove-markup"
|
|
|
|
|
"-d") ; spamassassin V2.20
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(if show-buffer
|
|
|
|
|
(kill-buffer show-buffer))
|
|
|
|
|
(write-file msg-file)
|
|
|
|
|
(when mh-sa-learn-executable
|
|
|
|
|
(message "Recategorizing this message as ham...")
|
|
|
|
|
(call-process mh-sa-learn-executable msg-file mh-temp-buffer nil
|
|
|
|
|
"--single" "--ham" "--local --no-rebuild"))
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Whitelisting message %d..." msg)
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(setq from
|
|
|
|
|
(car (mh-funcall-if-exists
|
|
|
|
|
ietf-drums-parse-address (mh-get-header-field "From:"))))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(kill-buffer nil)
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(unless (or (null from) (equal from ""))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(mh-spamassassin-add-rule "whitelist_from" from))
|
2005-09-18 12:48:32 +00:00
|
|
|
|
(message "Whitelisting message %d...done" msg))))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
|
|
|
|
(defun mh-spamassassin-add-rule (rule body)
|
2004-08-15 22:00:06 +00:00
|
|
|
|
"Add a new rule to `~/.spamassassin/user_prefs'.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
The name of the rule is RULE and its body is BODY."
|
|
|
|
|
(save-window-excursion
|
|
|
|
|
(let* ((line (format "%s\t%s\n" rule body))
|
|
|
|
|
(case-fold-search t)
|
|
|
|
|
(file (expand-file-name "~/.spamassassin/user_prefs"))
|
|
|
|
|
(buffer-exists (find-buffer-visiting file)))
|
|
|
|
|
(find-file file)
|
|
|
|
|
(if (not (search-forward (format "\n%s" line) nil t))
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(insert (if (bolp) "" "\n") line)
|
|
|
|
|
(save-buffer)))
|
|
|
|
|
(if (not buffer-exists)
|
|
|
|
|
(kill-buffer nil)))))
|
|
|
|
|
|
|
|
|
|
(defun mh-spamassassin-identify-spammers ()
|
2004-08-15 22:00:06 +00:00
|
|
|
|
"Identify spammers who are repeat offenders.
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
This function displays a frequency count of the hosts and domains in the
|
|
|
|
|
`blacklist_from' entries from the last blank line in
|
|
|
|
|
`~/.spamassassin/user_prefs' to the end of the file. This information can be
|
|
|
|
|
used so that you can replace multiple `blacklist_from' entries with a single
|
|
|
|
|
wildcard entry such as:
|
2003-04-25 05:52:00 +00:00
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
blacklist_from *@*amazingoffersdirect2u.com"
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(interactive)
|
|
|
|
|
(let* ((file (expand-file-name "~/.spamassassin/user_prefs"))
|
|
|
|
|
(domains (make-hash-table :test 'equal)))
|
|
|
|
|
(find-file file)
|
|
|
|
|
;; Only consider entries between last blank line and end of file.
|
|
|
|
|
(goto-char (1- (point-max)))
|
|
|
|
|
(search-backward-regexp "^$")
|
|
|
|
|
;; Perform frequency count.
|
|
|
|
|
(save-excursion
|
|
|
|
|
(while (search-forward-regexp "^blacklist_from\\s-*\\(.*\\)@\\(.*\\)$"
|
|
|
|
|
nil t)
|
|
|
|
|
(let ((host (match-string 2))
|
|
|
|
|
value)
|
|
|
|
|
;; Remove top-level-domain from hostname.
|
|
|
|
|
(setq host (cdr (reverse (split-string host "\\."))))
|
|
|
|
|
;; Add counts for each host and domain part.
|
|
|
|
|
(while host
|
|
|
|
|
(setq value (gethash (car host) domains))
|
2004-08-15 22:00:06 +00:00
|
|
|
|
(setf (gethash (car host) domains) (1+ (if (not value) 0 value)))
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(setq host (cdr host))))))
|
|
|
|
|
|
|
|
|
|
;; Output
|
|
|
|
|
(delete-other-windows)
|
|
|
|
|
(pop-to-buffer (get-buffer-create "*MH-E Spammer Frequencies*"))
|
|
|
|
|
(erase-buffer)
|
|
|
|
|
(maphash '(lambda (key value) ""
|
|
|
|
|
(if (> value 2)
|
|
|
|
|
(insert (format "%s %s\n" key value))))
|
|
|
|
|
domains)
|
|
|
|
|
(sort-numeric-fields 2 (point-min) (point-max))
|
|
|
|
|
(reverse-region (point-min) (point-max))
|
|
|
|
|
(goto-char (point-min))))
|
|
|
|
|
|
2004-08-15 22:00:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Bogofilter Interface
|
|
|
|
|
|
|
|
|
|
(defvar mh-bogofilter-executable (executable-find "bogofilter"))
|
|
|
|
|
|
|
|
|
|
(defun mh-bogofilter-blacklist (msg)
|
|
|
|
|
"Blacklist MSG with Bogofilter.
|
|
|
|
|
|
|
|
|
|
Bogofilter is a Bayesian spam filtering program. Get it from your local
|
|
|
|
|
distribution or from http://bogofilter.sourceforge.net/.
|
|
|
|
|
|
|
|
|
|
Bogofilter is taught by running:
|
|
|
|
|
|
|
|
|
|
bogofilter -n < good-message
|
|
|
|
|
|
|
|
|
|
on every good message, and
|
|
|
|
|
|
|
|
|
|
bogofilter -s < spam-message
|
|
|
|
|
|
|
|
|
|
on every spam message. This is called a full training; three other
|
|
|
|
|
training methods are described in the FAQ that is distributed with bogofilter.
|
|
|
|
|
Note that most Bayesian filters need 1000 to 5000 of each type of message to
|
|
|
|
|
start doing a good job.
|
|
|
|
|
|
|
|
|
|
To use Bogofilter, add the following recipes to `.procmailrc':
|
|
|
|
|
|
|
|
|
|
MAILDIR=$HOME/`mhparam Path`
|
|
|
|
|
|
|
|
|
|
# Fight spam with Bogofilter.
|
|
|
|
|
:0fw
|
|
|
|
|
| bogofilter -3 -e -p
|
|
|
|
|
|
|
|
|
|
:0:
|
|
|
|
|
* ^X-Bogosity: Yes, tests=bogofilter
|
|
|
|
|
spam/.
|
|
|
|
|
|
|
|
|
|
:0:
|
|
|
|
|
* ^X-Bogosity: Unsure, tests=bogofilter
|
|
|
|
|
spam/unsure/.
|
|
|
|
|
|
|
|
|
|
If Bogofilter classifies a message incorrectly, or is unsure, you can use the
|
|
|
|
|
MH-E commands \\[mh-junk-blacklist] and \\[mh-junk-whitelist] to update
|
|
|
|
|
Bogofilter's training.
|
|
|
|
|
|
|
|
|
|
The \"Bogofilter FAQ\" suggests that you run the following
|
|
|
|
|
occasionally to shrink the database:
|
|
|
|
|
|
|
|
|
|
bogoutil -d wordlist.db | bogoutil -l wordlist.db.new
|
|
|
|
|
mv wordlist.db wordlist.db.prv
|
|
|
|
|
mv wordlist.db.new wordlist.db
|
|
|
|
|
|
|
|
|
|
The \"Bogofilter tuning HOWTO\" describes how you can fine-tune Bogofilter."
|
|
|
|
|
(unless mh-bogofilter-executable
|
|
|
|
|
(error "Unable to find the bogofilter executable"))
|
|
|
|
|
(let ((msg-file (mh-msg-filename msg mh-current-folder)))
|
|
|
|
|
(call-process mh-bogofilter-executable msg-file mh-junk-background
|
|
|
|
|
nil "-s")))
|
|
|
|
|
|
|
|
|
|
(defun mh-bogofilter-whitelist (msg)
|
|
|
|
|
"Whitelist MSG with Bogofilter.
|
|
|
|
|
|
|
|
|
|
See `mh-bogofilter-blacklist' for more information."
|
|
|
|
|
(unless mh-bogofilter-executable
|
|
|
|
|
(error "Unable to find the bogofilter executable"))
|
|
|
|
|
(let ((msg-file (mh-msg-filename msg mh-current-folder)))
|
|
|
|
|
(call-process mh-bogofilter-executable msg-file mh-junk-background
|
|
|
|
|
nil "-n")))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Spamprobe Interface
|
|
|
|
|
|
|
|
|
|
(defvar mh-spamprobe-executable (executable-find "spamprobe"))
|
|
|
|
|
|
|
|
|
|
(defun mh-spamprobe-blacklist (msg)
|
|
|
|
|
"Blacklist MSG with SpamProbe.
|
|
|
|
|
|
|
|
|
|
SpamProbe is a Bayesian spam filtering program. Get it from your local
|
|
|
|
|
distribution or from http://spamprobe.sourceforge.net.
|
|
|
|
|
|
|
|
|
|
To use SpamProbe, add the following recipes to `.procmailrc':
|
|
|
|
|
|
|
|
|
|
MAILDIR=$HOME/`mhparam Path`
|
|
|
|
|
|
|
|
|
|
# Fight spam with SpamProbe.
|
|
|
|
|
:0
|
|
|
|
|
SCORE=| spamprobe receive
|
|
|
|
|
|
|
|
|
|
:0 wf
|
|
|
|
|
| formail -I \"X-SpamProbe: $SCORE\"
|
|
|
|
|
|
|
|
|
|
:0:
|
|
|
|
|
*^X-SpamProbe: SPAM
|
|
|
|
|
spam/.
|
|
|
|
|
|
|
|
|
|
If SpamProbe classifies a message incorrectly, you can use the MH-E commands
|
|
|
|
|
\\[mh-junk-blacklist] and \\[mh-junk-whitelist] to update SpamProbe's
|
|
|
|
|
training."
|
|
|
|
|
(unless mh-spamprobe-executable
|
|
|
|
|
(error "Unable to find the spamprobe executable"))
|
|
|
|
|
(let ((msg-file (mh-msg-filename msg mh-current-folder)))
|
|
|
|
|
(call-process mh-spamprobe-executable msg-file mh-junk-background
|
|
|
|
|
nil "spam")))
|
|
|
|
|
|
|
|
|
|
(defun mh-spamprobe-whitelist (msg)
|
|
|
|
|
"Whitelist MSG with SpamProbe.
|
|
|
|
|
|
|
|
|
|
See `mh-spamprobe-blacklist' for more information."
|
|
|
|
|
(unless mh-spamprobe-executable
|
|
|
|
|
(error "Unable to find the spamprobe executable"))
|
|
|
|
|
(let ((msg-file (mh-msg-filename msg mh-current-folder)))
|
|
|
|
|
(call-process mh-spamprobe-executable msg-file mh-junk-background
|
|
|
|
|
nil "good")))
|
|
|
|
|
|
2003-04-25 05:52:00 +00:00
|
|
|
|
(provide 'mh-junk)
|
|
|
|
|
|
|
|
|
|
;;; Local Variables:
|
|
|
|
|
;;; indent-tabs-mode: nil
|
|
|
|
|
;;; sentence-end-double-space: nil
|
|
|
|
|
;;; End:
|
|
|
|
|
|
2003-09-01 15:45:59 +00:00
|
|
|
|
;;; arch-tag: 603335f1-77ff-4306-8828-5d3dad51abe1
|
2003-04-25 05:52:00 +00:00
|
|
|
|
;;; mh-junk.el ends here
|