weblog d’un abbe


A Gnus Hack

Filed under: Hacking — Tags: , , , , — abbe @ 1317
;; Add to ~/.gnus
(defcustom my-inline-pgp-mails-list
  "List of email address which only accept inline-PGP signed mails"
  :type '(repeat string))

(defun my-list-all-recipients()
  "Lists all recipients in the current buffer"
  (let ((list-of-recipients)
        (list-of-emails '()))
    (setq list-of-recipients (split-string (concat (message-fetch-field "to") ","
                                     (message-fetch-field "bcc") ","
                                     (message-fetch-field "cc")) ","))
    (dolist (recipient list-of-recipients)
      (when (string-match "\\([[:alnum:].-]+@[[:alnum:].-]*\\)" recipient)
        (add-to-list 'list-of-emails (match-string 1 recipient))))

(defun my-sign-mail()
  "Sends a PGP signed mail depending on whether recipient allows PGP/MIME signed mails"
  (let ((recipients (my-list-all-recipients))
        (message-signed nil))
    (dolist (email my-inline-pgp-mails-list)
      (when (member email recipients)
        (message "Recipient found as %s" email)
        (setq message-signed t)
        (return t)))
    (unless message-signed

(add-hook 'message-send-hook 'my-sign-mail)

Above Emacs Lisp code allows one to send PGP signed messages, in the way preferred by recipient. e.g. There are some lists which don’t allow multipart/signed message, so in order to post to those lists, one needs to send inline PGP signed messages. This piece of code takes care of all that. All you need to do is to specify email addresses which don’t acceptmultipart/signed messages using M-x customize-variable my-inline-pgp-mails-list. Happy Gnusing… ;)

P.S. The code is also pasted at paste.lisp.org.

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: