/[emacs]/emacs/lisp/mh-e/mh-junk.el
ViewVC logotype

Diff of /emacs/lisp/mh-e/mh-junk.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2.2.2 by miles, Sat Jul 17 02:51:49 2004 UTC revision 1.2.2.3 by miles, Sat Sep 4 09:22:56 2004 UTC
# Line 1  Line 1 
1  ;;; mh-junk.el --- Interface to anti-spam measures  ;;; mh-junk.el --- Interface to anti-spam measures
2    
3  ;; Copyright (C) 2003 Free Software Foundation, Inc.  ;; Copyright (C) 2003, 2004 Free Software Foundation, Inc.
4    
5  ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>,  ;; Author: Satyaki Das <satyaki@theforce.stanford.edu>,
6  ;;         Bill Wohler <wohler@newt.com>  ;;         Bill Wohler <wohler@newt.com>
# Line 32  Line 32 
32    
33  ;;; Code:  ;;; Code:
34    
35    (eval-when-compile (require 'mh-acros))
36    (mh-require-cl)
37  (require 'mh-e)  (require 'mh-e)
38    
39  ;; Interactive functions callable from the folder buffer  ;; Interactive functions callable from the folder buffer
# Line 39  Line 41 
41  (defun mh-junk-blacklist (range)  (defun mh-junk-blacklist (range)
42    "Blacklist RANGE as spam.    "Blacklist RANGE as spam.
43    
44  Check the documentation of `mh-interactive-range' to see how RANGE is read in  This command trains the spam program in use (see the `mh-junk-program' option)
45  interactive use.  with the content of the range (see `mh-interactive-range') and then handles
46    the message(s) as specified by the `mh-junk-disposition' option.
47    
48  First the appropriate function is called depending on the value of  For more information about using your particular spam fighting program, see:
 `mh-junk-choice'. Then if `mh-junk-mail-folder' is a string then the message is  
 refiled to that folder. If nil, the message is deleted.  
   
 To change the spam program being used, customize `mh-junk-program'. Directly  
 setting `mh-junk-choice' is not recommended.  
   
 The documentation for the following functions describes what setup is needed  
 for the different spam fighting programs:  
49    
50      - `mh-spamassassin-blacklist'
51    - `mh-bogofilter-blacklist'    - `mh-bogofilter-blacklist'
52    - `mh-spamprobe-blacklist'    - `mh-spamprobe-blacklist'"
   - `mh-spamassassin-blacklist'"  
53    (interactive (list (mh-interactive-range "Blacklist")))    (interactive (list (mh-interactive-range "Blacklist")))
54    (let ((blacklist-func (nth 1 (assoc mh-junk-choice mh-junk-function-alist))))    (let ((blacklist-func (nth 1 (assoc mh-junk-choice mh-junk-function-alist))))
55      (unless blacklist-func      (unless blacklist-func
56        (error "Customize `mh-junk-program' appropriately"))        (error "Customize `mh-junk-program' appropriately"))
57      (let ((dest (cond ((null mh-junk-mail-folder) nil)      (let ((dest (cond ((null mh-junk-disposition) nil)
58                        ((equal mh-junk-mail-folder "") "+")                        ((equal mh-junk-disposition "") "+")
59                        ((eq (aref mh-junk-mail-folder 0) ?+)                        ((eq (aref mh-junk-disposition 0) ?+)
60                         mh-junk-mail-folder)                         mh-junk-disposition)
61                        ((eq (aref mh-junk-mail-folder 0) ?@)                        ((eq (aref mh-junk-disposition 0) ?@)
62                         (concat mh-current-folder "/"                         (concat mh-current-folder "/"
63                                 (substring mh-junk-mail-folder 1)))                                 (substring mh-junk-disposition 1)))
64                        (t (concat "+" mh-junk-mail-folder)))))                        (t (concat "+" mh-junk-disposition)))))
65        (mh-iterate-on-range msg range        (mh-iterate-on-range msg range
66            (message (format "Blacklisting message %d..." msg))
67          (funcall (symbol-function blacklist-func) msg)          (funcall (symbol-function blacklist-func) msg)
68            (message (format "Blacklisting message %d...done" msg))
69            (if (not (memq msg mh-seen-list))
70                (setq mh-seen-list (cons msg mh-seen-list)))
71          (if dest          (if dest
72              (mh-refile-a-msg nil (intern dest))              (mh-refile-a-msg nil (intern dest))
73            (mh-delete-a-msg nil)))            (mh-delete-a-msg nil)))
# Line 76  for the different spam fighting programs Line 75  for the different spam fighting programs
75    
76  ;;;###mh-autoload  ;;;###mh-autoload
77  (defun mh-junk-whitelist (range)  (defun mh-junk-whitelist (range)
78    "Whitelist RANGE incorrectly classified as spam.    "Whitelist RANGE as ham.
79    
80  Check the documentation of `mh-interactive-range' to see how RANGE is read in  This command reclassifies a range of messages (see `mh-interactive-range') as
81  interactive use.  ham if it were incorrectly classified as spam. It then refiles the message
82    into the `+inbox' folder.
83    
84  First the appropriate function is called depending on the value of  The `mh-junk-program' option specifies the spam program in use."
 `mh-junk-choice'. Then the message is refiled to `mh-inbox'.  
   
 To change the spam program being used, customize `mh-junk-program'. Directly  
 setting `mh-junk-choice' is not recommended."  
85    (interactive (list (mh-interactive-range "Whitelist")))    (interactive (list (mh-interactive-range "Whitelist")))
86    (let ((whitelist-func (nth 2 (assoc mh-junk-choice mh-junk-function-alist))))    (let ((whitelist-func (nth 2 (assoc mh-junk-choice mh-junk-function-alist))))
87      (unless whitelist-func      (unless whitelist-func
88        (error "Customize `mh-junk-program' appropriately"))        (error "Customize `mh-junk-program' appropriately"))
89      (mh-iterate-on-range msg range      (mh-iterate-on-range msg range
90          (message (format "Whitelisting message %d..." msg))
91        (funcall (symbol-function whitelist-func) msg)        (funcall (symbol-function whitelist-func) msg)
92          (message (format "Whitelisting message %d...done" msg))
93        (mh-refile-a-msg nil (intern mh-inbox)))        (mh-refile-a-msg nil (intern mh-inbox)))
94      (mh-next-msg)))      (mh-next-msg)))
95    
96    
97    
 ;; Bogofilter Interface  
   
 (defvar mh-bogofilter-executable (executable-find "bogofilter"))  
   
 (defun mh-bogofilter-blacklist (msg)  
   "Classify MSG as spam.  
 Tell bogofilter that the message is spam.  
   
 Bogofilter is a Bayesian spam filtering program. Get it from your local  
 distribution or from:  
    http://bogofilter.sourceforge.net/  
   
 You first need to teach bogofilter. This is done by running  
   
    bogofilter -n < good-message  
   
 on every good message, and  
   
    bogofilter -s < spam-message  
   
 on every spam message. Most Bayesian filters need 1000 to 5000 of each to  
 start doing a good job.  
   
 To use bogofilter, add the following .procmailrc recipes which you can also  
 find in the bogofilter man page:  
   
    # Bogofilter  
    :0fw  
    | bogofilter -u -e -p  
   
    :0  
    * ^X-Bogosity: Yes, tests=bogofilter  
    $SPAM  
   
 Bogofilter continues to feed the messages it classifies back into its  
 database. Occasionally it misses, and those messages need to be reclassified.  
 MH-E can do this for you. Use \\[mh-junk-blacklist] to reclassify messges in  
 your +inbox as spam, and \\[mh-junk-whitelist] to reclassify messages in your  
 spambox as good messages."  
   (unless mh-bogofilter-executable  
     (error "Couldn't find the bogofilter executable"))  
   (let ((msg-file (mh-msg-filename msg mh-current-folder)))  
     (call-process mh-bogofilter-executable msg-file 0 nil "-Ns")))  
   
 (defun mh-bogofilter-whitelist (msg)  
   "Reinstate incorrectly filtered MSG.  
 Train bogofilter to think of the message as non-spam."  
   (unless mh-bogofilter-executable  
     (error "Couldn't find the bogofilter executable"))  
   (let ((msg-file (mh-msg-filename msg mh-current-folder)))  
     (call-process mh-bogofilter-executable msg-file 0 nil "-Sn")))  
   
   
   
 ;; Spamprobe Interface  
   
 (defvar mh-spamprobe-executable (executable-find "spamprobe"))  
   
 (defun mh-spamprobe-blacklist (msg)  
   "Classify MSG as spam.  
 Tell spamprobe that the message is spam.  
   
 Spamprobe is a Bayesian spam filtering program. More info about the program can  
 be found at:  
    http://spamprobe.sourceforge.net  
   
 Here is a procmail recipe to stores incoming spam mail into the folder +spam  
 and good mail in /home/user/Mail/mdrop/mbox. This recipe is provided as an  
 example in the spamprobe man page.  
   
    PATH=/bin:/usr/bin:/usr/local/bin  
    DEFAULT=/home/user/Mail/mdrop/mbox  
    SPAM=/home/user/Mail/spam/.  
   
    # Spamprobe filtering  
    :0  
    SCORE=| spamprobe receive  
    :0 wf  
    | formail -I \"X-SpamProbe: $SCORE\"  
    :0 a:  
    *^X-SpamProbe: SPAM  
    $SPAM  
   
 Occasionally some good mail gets misclassified as spam. You can use  
 \\[mh-junk-whitelist] to reclassify that as good mail."  
   (unless mh-spamprobe-executable  
     (error "Couldn't find the spamprobe executable"))  
   (let ((msg-file (mh-msg-filename msg mh-current-folder)))  
     (call-process mh-spamprobe-executable msg-file 0 nil "spam")))  
   
 (defun mh-spamprobe-whitelist (msg)  
   "Reinstate incorrectly filtered MSG.  
 Train spamprobe to think of the message as non-spam."  
   (unless mh-spamprobe-executable  
     (error "Couldn't find the spamprobe executable"))  
   (let ((msg-file (mh-msg-filename msg mh-current-folder)))  
     (call-process mh-spamprobe-executable msg-file 0 nil "good")))  
   
   
   
98  ;; Spamassassin Interface  ;; Spamassassin Interface
99    
100  (defvar mh-spamassassin-executable (executable-find "spamassassin"))  (defvar mh-spamassassin-executable (executable-find "spamassassin"))
101  (defvar mh-sa-learn-executable (executable-find "sa-learn"))  (defvar mh-sa-learn-executable (executable-find "sa-learn"))
102    
103  (defun mh-spamassassin-blacklist (msg)  (defun mh-spamassassin-blacklist (msg)
104    "Blacklist MSG.    "Blacklist MSG with SpamAssassin.
105  This is done by sending the message to Razor and by appending the sender to  
106  ~/.spamassassin/user_prefs in a blacklist_from rule. If sa-learn is available,  SpamAssassin is one of the more popular spam filtering programs. Get it from
107  the message is also recategorized as spam.  your local distribution or from http://spamassassin.org/.
108    
109  Spamassassin is an excellent spam filter. For more information, see:  To use SpamAssassin, add the following recipes to `.procmailrc':
110    http://spamassassin.org/.  
111        MAILDIR=$HOME/`mhparam Path`
 I ran \"spamassassin -t\" on every mail message in my archive and ran an  
 analysis in Gnumeric to find that the standard deviation of good mail  
 scored under 5 (coincidentally, the spamassassin default for \"spam\").  
   
 Furthermore, I observed that there weren't any messages with a score of 8  
 or more that were interesting, so I added a couple of points to be  
 conservative and send any message with a score of 10 or more down the  
 drain. You might want to use a score of 12 or 13 to be really conservative.  
 I have found that this really decreases the amount of junk to review.  
   
 Messages with a score of 5-9 are set aside for later review. The major  
 weakness of rules-based filters is a plethora of false positives\; I catch one  
 or two legitimate messages in here a week, so it is worthwhile to check.  
   
 You might choose to do this analysis yourself to pick a good score for  
 deleting spam sight unseen, or you might pick a score out of a hat, or you  
 might choose to be very conservative and not delete any messages at all.  
   
 Based upon this discussion, here is what the associated ~/.procmailrc  
 entries look like. These rules appear before my list filters so that spam  
 sent to mailing lists gets pruned too.  
   
    #  
    # Spam  
    #  
    :0fw  
    | spamc  
   
    # Anything with a spam level of 10 or more is junked immediately.  
    :0:  
    * ^X-Spam-Level: ..........  
    /dev/null  
   
    :0  
    * ^X-Spam-Status: Yes  
    $SPAM  
   
 If you don't use \"spamc\", use \"spamassassin -P -a\".  
   
 A handful of spam does find its way into +inbox. In this case, use  
 \\[mh-junk-blacklist] to add a \"blacklist_from\" line to  
 ~/spamassassin/user_prefs, delete the message, and send the message to the  
 Razor, so that others might not see this spam.  
   
 Over time, you see some patterns in the blacklisted addresses and can  
 replace several lines with wildcards. For example, it is clear that High  
 Speed Media is the biggest bunch of jerks on the Net. Here are some of the  
 entries I have for them, and the list continues to grow.  
   
    blacklist_from       *@*-hsm-*.com  
    blacklist_from       *@*182*643*.com  
    blacklist_from       *@*antarhsm*.com  
    blacklist_from       *@*h*speed*  
    blacklist_from       *@*hsm*182*.com  
    blacklist_from       *@*hsm*643*.com  
    blacklist_from       *@*hsmridi2983cslt227.com  
    blacklist_from       *@*list*hsm*.com  
    blacklist_from       *@h*s*media*  
    blacklist_from       *@hsmdrct.com  
    blacklist_from       *@hsmridi2983csltsite.com  
   
 The function `mh-spamassassin-identify-spammers' is provided that shows the  
 frequency counts of the host and domain names in your blacklist_from  
 entries. This can be helpful when editing the blacklist_from entries.  
   
 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:  
112    
113    0 * * * *     sa-learn --rebuild > /dev/null 2>&1"      # Fight spam with SpamAssassin.
114        :0fw
115        | spamc
116    
117        # Anything with a spam level of 10 or more is junked immediately.
118        :0:
119        * ^X-Spam-Level: ..........
120        /dev/null
121    
122        :0:
123        * ^X-Spam-Status: Yes
124        spam/.
125    
126    If you don't use `spamc', use `spamassassin -P -a'.
127    
128    Note that one of the recipes above throws away messages with a score greater
129    than or equal to 10. Here's how you can determine a value that works best for
130    you.
131    
132    First, run `spamassassin -t' on every mail message in your archive and use
133    Gnumeric to verify that the average plus the standard deviation of good mail
134    is under 5, the SpamAssassin default for \"spam\".
135    
136    Using Gnumeric, sort the messages by score and view the messages with the
137    highest score. Determine the score which encompasses all of your interesting
138    messages and add a couple of points to be conservative. Add that many dots to
139    the `X-Spam-Level:' header field above to send messages with that score down
140    the drain.
141    
142    In the example above, messages with a score of 5-9 are set aside in the
143    `+spam' folder for later review. The major weakness of rules-based filters is
144    a plethora of false positives so it is worthwhile to check.
145    
146    If SpamAssassin classifies a message incorrectly, or is unsure, you can use
147    the MH-E commands \\[mh-junk-blacklist] and \\[mh-junk-whitelist].
148    
149    The \\[mh-junk-blacklist] command adds a `blacklist_from' entry to
150    `~/spamassassin/user_prefs', deletes the message, and sends the message to the
151    Razor, so that others might not see this spam. If the `sa-learn' command is
152    available, the message is also recategorized as spam.
153    
154    The \\[mh-junk-whitelist] command adds a `whitelist_from' rule to the
155    `~/.spamassassin/user_prefs' file. If the `sa-learn' command is available, the
156    message is also recategorized as ham.
157    
158    Over time, you'll observe that the same host or domain occurs repeatedly in
159    the `blacklist_from' entries, so you might think that you could avoid future
160    spam by blacklisting all mail from a particular domain. The utility function
161    `mh-spamassassin-identify-spammers' helps you do precisely that. This function
162    displays a frequency count of the hosts and domains in the `blacklist_from'
163    entries from the last blank line in `~/.spamassassin/user_prefs' to the end of
164    the file. This information can be used so that you can replace multiple
165    `blacklist_from' entries with a single wildcard entry such as:
166    
167        blacklist_from *@*amazingoffersdirect2u.com
168    
169    In versions of SpamAssassin (2.50 and on) that support a Bayesian classifier,
170    \\[mh-junk-blacklist] uses the `sa-learn' program to recategorize the message
171    as spam. Neither MH-E, nor SpamAssassin, rebuilds the database after adding
172    words, so you will need to run `sa-learn --rebuild' periodically. This can be
173    done by adding the following to your crontab:
174    
175        0 * * * *   sa-learn --rebuild > /dev/null 2>&1"
176    (unless mh-spamassassin-executable    (unless mh-spamassassin-executable
177      (error "Couldn't find the spamassassin executable"))      (error "Unable to find the spamassassin executable"))
178    (let ((current-folder mh-current-folder)    (let ((current-folder mh-current-folder)
179          (msg-file (mh-msg-filename msg mh-current-folder))          (msg-file (mh-msg-filename msg mh-current-folder))
180          (sender))          (sender))
181      (save-excursion      (save-excursion
182        (message "Giving this message the Razor...")        (message (format "Reporting message %d..." msg))
183        (mh-truncate-log-buffer)        (mh-truncate-log-buffer)
184        (call-process mh-spamassassin-executable msg-file mh-log-buffer nil        (call-process mh-spamassassin-executable msg-file mh-log-buffer nil
185                      "--report" "--remove-from-whitelist")                      ;;"--report" "--remove-from-whitelist"
186                        "-r" "-R")          ; spamassassin V2.20
187        (when mh-sa-learn-executable        (when mh-sa-learn-executable
188            (message "Recategorizing this message as spam...")            (message "Recategorizing this message as spam...")
189            (call-process mh-sa-learn-executable msg-file mh-log-buffer nil            (call-process mh-sa-learn-executable msg-file mh-log-buffer nil
190                          "--single" "--spam" "--local" "--no-rebuild"))                          "--single" "--spam" "--local" "--no-rebuild"))
191        (message "Blacklisting address...")        (message (format "Blacklisting message %d..." msg))
192        (set-buffer (get-buffer-create mh-temp-buffer))        (set-buffer (get-buffer-create mh-temp-buffer))
193        (erase-buffer)        (erase-buffer)
194        (call-process (expand-file-name mh-scan-prog mh-progs) nil t nil        (call-process (expand-file-name mh-scan-prog mh-progs) mh-junk-background
195                        t nil
196                      (format "%s" msg) current-folder                      (format "%s" msg) current-folder
197                      "-format" "%<(mymbox{from})%|%(addr{from})%>")                      "-format" "%<(mymbox{from})%|%(addr{from})%>")
198        (goto-char (point-min))        (goto-char (point-min))
# Line 308  be done by adding the following to your Line 200  be done by adding the following to your
200            (progn            (progn
201              (setq sender (match-string 0))              (setq sender (match-string 0))
202              (mh-spamassassin-add-rule "blacklist_from" sender)              (mh-spamassassin-add-rule "blacklist_from" sender)
203              (message "Blacklisting address...done"))              (message (format "Blacklisting message %d...done" msg)))
204          (message "Blacklisting address...not done (from my address)")))))          (message (format "Blacklisting message %d...not done (from my address)" msg))))))
205    
206  (defun mh-spamassassin-whitelist (msg)  (defun mh-spamassassin-whitelist (msg)
207    "Whitelist MSG.    "Whitelist MSG with SpamAssassin.
208  Add a whitelist_from rule to the ~/.spamassassin/user_prefs file. If sa-learn  
209  is available, then the message is recategorized as ham."  The \\[mh-junk-whitelist] command adds a `whitelist_from' rule to the
210    `~/.spamassassin/user_prefs' file. If the `sa-learn' command is available, the
211    message is also recategorized as ham.
212    
213    See `mh-spamassassin-blacklist' for more information."
214    (unless mh-spamassassin-executable    (unless mh-spamassassin-executable
215      (error "Couldn't find the spamassassin executable"))      (error "Unable to find the spamassassin executable"))
216    (let ((msg-file (mh-msg-filename msg mh-current-folder))    (let ((msg-file (mh-msg-filename msg mh-current-folder))
217          (show-buffer (get-buffer mh-show-buffer))          (show-buffer (get-buffer mh-show-buffer))
218          from)          from)
# Line 325  is available, then the message is recate Line 221  is available, then the message is recate
221        (erase-buffer)        (erase-buffer)
222        (message "Removing spamassassin markup from message...")        (message "Removing spamassassin markup from message...")
223        (call-process mh-spamassassin-executable msg-file mh-temp-buffer nil        (call-process mh-spamassassin-executable msg-file mh-temp-buffer nil
224                      "--remove-markup")                      ;; "--remove-markup"
225                        "-d")               ; spamassassin V2.20
226        (if show-buffer        (if show-buffer
227            (kill-buffer show-buffer))            (kill-buffer show-buffer))
228        (write-file msg-file)        (write-file msg-file)
# Line 333  is available, then the message is recate Line 230  is available, then the message is recate
230          (message "Recategorizing this message as ham...")          (message "Recategorizing this message as ham...")
231          (call-process mh-sa-learn-executable msg-file mh-temp-buffer nil          (call-process mh-sa-learn-executable msg-file mh-temp-buffer nil
232                        "--single" "--ham" "--local --no-rebuild"))                        "--single" "--ham" "--local --no-rebuild"))
233        (message "Whitelisting address...")        (message (format "Whitelisting message %d..." msg))
234        (setq from (car (ietf-drums-parse-address (mh-get-header-field "From:"))))        (setq from
235                (car (mh-funcall-if-exists
236                      ietf-drums-parse-address (mh-get-header-field "From:"))))
237        (kill-buffer nil)        (kill-buffer nil)
238        (unless (equal from "")        (unless (or (null from) (equal from ""))
239          (mh-spamassassin-add-rule "whitelist_from" from))          (mh-spamassassin-add-rule "whitelist_from" from))
240        (message "Whitelisting address...done"))))        (message (format "Whitelisting message %d...done" msg)))))
241    
242  (defun mh-spamassassin-add-rule (rule body)  (defun mh-spamassassin-add-rule (rule body)
243    "Add a new rule to ~/.spamassassin/user_prefs.    "Add a new rule to `~/.spamassassin/user_prefs'.
244  The name of the rule is RULE and its body is BODY."  The name of the rule is RULE and its body is BODY."
245    (save-window-excursion    (save-window-excursion
246      (let* ((line (format "%s\t%s\n" rule body))      (let* ((line (format "%s\t%s\n" rule body))
# Line 358  The name of the rule is RULE and its bod Line 257  The name of the rule is RULE and its bod
257            (kill-buffer nil)))))            (kill-buffer nil)))))
258    
259  (defun mh-spamassassin-identify-spammers ()  (defun mh-spamassassin-identify-spammers ()
260    "Identifies spammers who are repeat offenders.    "Identify spammers who are repeat offenders.
261    
262  For each blacklist_from entry from the last blank line of  This function displays a frequency count of the hosts and domains in the
263  ~/.spamassassin/user_prefs to the end of the file, a list of host and domain  `blacklist_from' entries from the last blank line in
264  names along with their frequency counts is displayed. This information can be  `~/.spamassassin/user_prefs' to the end of the file. This information can be
265  used to replace multiple blacklist_from entries with a single wildcard entry  used so that you can replace multiple `blacklist_from' entries with a single
266  such as:  wildcard entry such as:
267    
268    blacklist_from *@*amazingoffersdirect2u.com"      blacklist_from *@*amazingoffersdirect2u.com"
269    (interactive)    (interactive)
270    (let* ((file (expand-file-name "~/.spamassassin/user_prefs"))    (let* ((file (expand-file-name "~/.spamassassin/user_prefs"))
271           (domains (make-hash-table :test 'equal)))           (domains (make-hash-table :test 'equal)))
# Line 385  such as: Line 284  such as:
284            ;; Add counts for each host and domain part.            ;; Add counts for each host and domain part.
285            (while host            (while host
286              (setq value (gethash (car host) domains))              (setq value (gethash (car host) domains))
287              (puthash (car host) (1+ (if (not value) 0 value)) domains)              (setf (gethash (car host) domains) (1+ (if (not value) 0 value)))
288              (setq host (cdr host))))))              (setq host (cdr host))))))
289    
290      ;; Output      ;; Output
# Line 400  such as: Line 299  such as:
299      (reverse-region (point-min) (point-max))      (reverse-region (point-min) (point-max))
300      (goto-char (point-min))))      (goto-char (point-min))))
301    
302    
303    
304    ;; Bogofilter Interface
305    
306    (defvar mh-bogofilter-executable (executable-find "bogofilter"))
307    
308    (defun mh-bogofilter-blacklist (msg)
309      "Blacklist MSG with Bogofilter.
310    
311    Bogofilter is a Bayesian spam filtering program. Get it from your local
312    distribution or from http://bogofilter.sourceforge.net/.
313    
314    Bogofilter is taught by running:
315    
316        bogofilter -n < good-message
317    
318    on every good message, and
319    
320        bogofilter -s < spam-message
321    
322    on every spam message. This is called a full training; three other
323    training methods are described in the FAQ that is distributed with bogofilter.
324    Note that most Bayesian filters need 1000 to 5000 of each type of message to
325    start doing a good job.
326    
327    To use Bogofilter, add the following recipes to `.procmailrc':
328    
329        MAILDIR=$HOME/`mhparam Path`
330    
331        # Fight spam with Bogofilter.
332        :0fw
333        | bogofilter -3 -e -p
334    
335        :0:
336        * ^X-Bogosity: Yes, tests=bogofilter
337        spam/.
338    
339        :0:
340        * ^X-Bogosity: Unsure, tests=bogofilter
341        spam/unsure/.
342    
343    If Bogofilter classifies a message incorrectly, or is unsure, you can use the
344    MH-E commands \\[mh-junk-blacklist] and \\[mh-junk-whitelist] to update
345    Bogofilter's training.
346    
347    The \"Bogofilter FAQ\" suggests that you run the following
348    occasionally to shrink the database:
349    
350        bogoutil -d wordlist.db | bogoutil -l wordlist.db.new
351        mv wordlist.db wordlist.db.prv
352        mv wordlist.db.new wordlist.db
353    
354    The \"Bogofilter tuning HOWTO\" describes how you can fine-tune Bogofilter."
355      (unless mh-bogofilter-executable
356        (error "Unable to find the bogofilter executable"))
357      (let ((msg-file (mh-msg-filename msg mh-current-folder)))
358        (call-process mh-bogofilter-executable msg-file mh-junk-background
359                      nil "-s")))
360    
361    (defun mh-bogofilter-whitelist (msg)
362      "Whitelist MSG with Bogofilter.
363    
364    See `mh-bogofilter-blacklist' for more information."
365      (unless mh-bogofilter-executable
366        (error "Unable to find the bogofilter executable"))
367      (let ((msg-file (mh-msg-filename msg mh-current-folder)))
368        (call-process mh-bogofilter-executable msg-file mh-junk-background
369                      nil "-n")))
370    
371    
372    
373    ;; Spamprobe Interface
374    
375    (defvar mh-spamprobe-executable (executable-find "spamprobe"))
376    
377    (defun mh-spamprobe-blacklist (msg)
378      "Blacklist MSG with SpamProbe.
379    
380    SpamProbe is a Bayesian spam filtering program. Get it from your local
381    distribution or from http://spamprobe.sourceforge.net.
382    
383    To use SpamProbe, add the following recipes to `.procmailrc':
384    
385        MAILDIR=$HOME/`mhparam Path`
386    
387        # Fight spam with SpamProbe.
388        :0
389        SCORE=| spamprobe receive
390    
391        :0 wf
392        | formail -I \"X-SpamProbe: $SCORE\"
393    
394        :0:
395        *^X-SpamProbe: SPAM
396        spam/.
397    
398    If SpamProbe classifies a message incorrectly, you can use the MH-E commands
399    \\[mh-junk-blacklist] and \\[mh-junk-whitelist] to update SpamProbe's
400    training."
401      (unless mh-spamprobe-executable
402        (error "Unable to find the spamprobe executable"))
403      (let ((msg-file (mh-msg-filename msg mh-current-folder)))
404        (call-process mh-spamprobe-executable msg-file mh-junk-background
405                      nil "spam")))
406    
407    (defun mh-spamprobe-whitelist (msg)
408      "Whitelist MSG with SpamProbe.
409    
410    See `mh-spamprobe-blacklist' for more information."
411      (unless mh-spamprobe-executable
412        (error "Unable to find the spamprobe executable"))
413      (let ((msg-file (mh-msg-filename msg mh-current-folder)))
414        (call-process mh-spamprobe-executable msg-file mh-junk-background
415                      nil "good")))
416    
417  (provide 'mh-junk)  (provide 'mh-junk)
418    
419  ;;; Local Variables:  ;;; Local Variables:

Legend:
Removed from v.1.2.2.2  
changed lines
  Added in v.1.2.2.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26