Function: mh-spamassassin-blocklist
mh-spamassassin-blocklist is an autoloaded and byte-compiled function
defined in mh-junk.el.gz.
Signature
(mh-spamassassin-blocklist MSG)
Documentation
Blocklist MSG with SpamAssassin.
SpamAssassin is one of the more popular spam filtering programs. Get it from your local distribution or from the SpamAssassin web site at URL https://spamassassin.apache.org/.
To use SpamAssassin, add the following recipes to
".procmailrc":
PATH=$PATH:/usr/bin/mh
MAILDIR=$HOME/`mhparam Path
# Fight spam with SpamAssassin.
: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 dont use "spamc", use "spamassassin".
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.
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".
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.
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.
If SpamAssassin classifies a message incorrectly, or is unsure,
you can use the MH-E commands M-x mh-junk-blocklist (mh-junk-blocklist) and
M-x mh-junk-allowlist (mh-junk-allowlist).
The command M-x mh-junk-blocklist (mh-junk-blocklist) 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.
The command M-x mh-junk-allowlist (mh-junk-allowlist) 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.
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 blocklisting 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:
blacklist_from *@*amazingoffersdirect2u.com
Source Code
;; Defined in /usr/src/emacs/lisp/mh-e/mh-junk.el.gz
;;;###mh-autoload
(defun mh-spamassassin-blocklist (msg)
"Blocklist MSG with SpamAssassin.
SpamAssassin is one of the more popular spam filtering programs.
Get it from your local distribution or from the SpamAssassin web
site at URL `https://spamassassin.apache.org/'.
To use SpamAssassin, add the following recipes to
\".procmailrc\":
PATH=$PATH:/usr/bin/mh
MAILDIR=$HOME/`mhparam Path`
# Fight spam with SpamAssassin.
: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\".
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.
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\".
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.
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.
If SpamAssassin classifies a message incorrectly, or is unsure,
you can use the MH-E commands \\[mh-junk-blocklist] and
\\[mh-junk-allowlist].
The command \\[mh-junk-blocklist] 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.
The command \\[mh-junk-allowlist] 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.
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 blocklisting 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:
blacklist_from *@*amazingoffersdirect2u.com"
(unless mh-spamassassin-executable
(error "Unable to find the spamassassin executable"))
(let ((current-folder mh-current-folder)
(msg-file (mh-msg-filename msg mh-current-folder))
(sender))
(message "Reporting message %d as spam with spamassassin..." msg)
(mh-truncate-log-buffer)
;; Put call-process output in log buffer if we are saving it
;; (this happens if mh-junk-background is t).
(with-current-buffer mh-log-buffer
(call-process mh-spamassassin-executable msg-file mh-junk-background nil
;; -R removes from allowlist
"--report" "-R")
(when mh-sa-learn-executable
(message "Recategorizing message %d as spam with sa-learn..." msg)
(mh-truncate-log-buffer)
(call-process mh-sa-learn-executable msg-file mh-junk-background nil
"--spam" "--local" "--no-sync")))
(message "Blocklisting sender of message %d..." msg)
(with-current-buffer (get-buffer-create mh-temp-buffer)
(erase-buffer)
(call-process (expand-file-name mh-scan-prog mh-progs)
nil t nil
(format "%d" 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)
(message "Blocklisting sender of message %d...done" msg))
(message "Blocklisting sender of message %d...not done (from my address)" msg)))))