I configured emacs to automatically sign emails:

(add-hook 'mu4e-compose-mode-hook 'mml-secure-message-sign)

However, mailing lists often add a footer to the message and that breaks the signature. Also some people are consistently confused by the attached signatures, and in these cases I'd prefer if the message wasn't signed. (These people are not going to check the signature anyway.)

What's the best way to implement a blacklist of email addresses such that emails to addresses on that list are not automatically signed?

1 Answer 1


The following will prevent messages to email addresses in blacklist-addresses from invoking mml-secure-message-sign.

(defvar blacklist-addresses nil
  "List of email addresses (as strings) to blacklist for

(defun secure-sign-maybe ()
  "Use `mml-secure-message-sign' unless the addressee is in the
  (let ((addresses (mapcar (lambda (address)
                             (when (string-match
                                    "\\(<?\\)\\([^@< ]+@[^@> ]+\\)\\(>?\\)"
                               (match-string 2 address)))
                           ;; (split-string (message-field-value "To")
                           ;;               "," t "[[:blank:]]+"))))
                           (split-string (concat (message-field-value "To")
                                                 ", "
                                                 (message-field-value "Cc"))
                                         "," t "[[:blank:]]+"))))
    ;; skip secure signing when an address is blacklisted
    (unless (delq nil (mapcar (lambda (address)
                                (car (member address blacklist-addresses)))

(add-hook 'message-send-hook #'secure-sign-maybe)

Right now, the code looks for addresses in the "To" and "Cc" fields. If you want it to check only the "To" field, comment out the existing call to split-string and uncomment the commented version.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.