| Paste number 63535: | Send (inline|MIME) PGP signed mails depending on recipient's policy |
| Pasted by: | abbe |
| When: | 1 year, 6 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+1D0V |
| Channel: | None |
| Paste contents: |
(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"
(interactive)
(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))))
list-of-emails))
(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)
(mml-secure-sign-pgp)
(setq message-signed t)
(return t)))
(unless message-signed
(mml-secure-message-sign-pgpmime))))
(add-hook 'message-send-hook 'my-sign-mail)This paste has no annotations.