Mailreaver is a script for CRM114, the “Controllable Regex Mutilator” (see For installing and configuring CRM114 see the following HOWTO:

While spam.el supports the mailfilter.crm script from CRM114, I prefer Mailreaver and like to filter my spam directly on the server through procmail anyway. This is why I wrote a little script for training messages for Mailreaver from the Gnus summary buffer:

(setq my-crm114-crm-command "ssh MY-IMAP-SERVER crm -u MY-CRM114-DIRECTORY mailreaver.crm --fileprefix=MY-CRM114-DIRECTORY")

(defun my-crm114-learn ()
  (unless (gnus-buffer-live-p gnus-article-buffer)
    (error "No article buffer available"))
    (set-buffer gnus-article-buffer)
      (let ((commandsplit (split-string my-crm114-crm-command))
	    (outbuf (get-buffer-create "*crm114 output*"))
	    (spamflag (y-or-n-p "Is this spam? ")))
	(gnus-summary-toggle-header 1)
	(unless (re-search-forward "^X-CRM114-CacheID:" nil t)
	  (error "No CRM144-CacheID header found"))
	(nconc commandsplit
	       (if spamflag
	(if (zerop (apply 'call-process-region 
			  (point) (progn (end-of-line) (point)) 
			  (car commandsplit) nil outbuf
			  nil (cdr commandsplit)))
	      (set-buffer outbuf)
	      (goto-char (point-max))
	      (re-search-backward "^X-CRM114-Action: \\(.*\\)" nil t)
	      (message (match-string 1))
	  (error "Calling crm failed"))))))

You can bind this script to a key combination by using

(define-key gnus-summary-mode-map
  (kbd "<KEY COMBINATION>") 'my-crm114-learn)

To display the CRM114 headers, simply include ^X-CRM114-\\(Status\\|Notice\\) in gnus-visible-headers.

Another nice feature is to sort the mails in the spam group with the score provided by CRM114, so that articles with the lowest spam probability are right at the top. This way it is easier to spot false positives, i.e. mails which were wrongly identified as spam (those will usually have a relatively low spam probability).

First you will have to put X-CRM114-Status into your gnus-extra-headers. I use the following:

(setq gnus-extra-headers '(To Newsgroups X-CRM114-Status))

Then you can use the following sort function:

(defun my-gnus-article-sort-by-crm114-score (h1 h2)
  (let ((n1 (gnus-extra-header 'X-CRM114-Status h1))
	(n2 (gnus-extra-header 'X-CRM114-Status h2)))
	(string-match "(\\(.*\\))" n2)
	(match-string 1 n2)))
	(string-match "(\\(.*\\))" n1)
	(match-string 1 n1))))))

You can set this sort function in the group parameters of your spam group (do ‘G c’ on your spam group and at the end under ‘variables’ set gnus-article-sort-functions to 'my-gnus-article-sort-by-crm114-score).

CategoryGnus SpamFiltering