Function: mh-spamassassin-identify-spammers

mh-spamassassin-identify-spammers is an autoloaded, interactive and byte-compiled function defined in mh-junk.el.gz.

Signature

(mh-spamassassin-identify-spammers)

Documentation

Identify spammers who are repeat offenders.

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

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/mh-e/mh-junk.el.gz
;;;###mh-autoload
(defun mh-spamassassin-identify-spammers ()
  "Identify spammers who are repeat offenders.

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"
  (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))
            (setf (gethash (car host) domains) (1+ (if (not value) 0 value)))
            (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))))