Hallo Klaus, Klaus Uhl writes: > The problem is that Gnus separately encrypts a mail for _all_ > recipients and if you have a recipient without a PGP key you will get > an error message. Indeed. > I tried to fix this problem with the following code: > > (defun extract-addresses (header-string) > (when (not (null header-string)) > (mapcar #'car (mail-header-parse-addresses header-string)))) > (add-hook > 'message-send-hook > (lambda () > (let* ((to-header (message-fetch-field "To")) > (cc-header (message-fetch-field "Cc")) > (bcc-header (message-fetch-field "Bcc")) > (to (when (not (null to-header)) (substring to-header 3))) > (cc (when (not (null cc-header)) (substring cc-header 3))) > (bcc (when (not (null bcc-header)) (substring bcc-header 4))) > (recipients > (append (extract-addresses to) > (extract-addresses cc) > (extract-addresses bcc)))) > (cond ((every (lambda (rec) > (or > (pgg-lookup-key rec) > (pgg-fetch-key pgg-default-keyserver-address rec))) > recipients) > (mml-secure-message-encrypt-pgpmime)) > (t > (mml-secure-message-sign-pgpmime)))))) > > You can see that I read all three headers, strip off the header > "prefix", extract all addresses and concatenate them to a single > list. Then I test if _all_ recipients have a PGP key. > > The only problem is: it does not work! It always tries to encrypt the > messages. Does anyone have an idea/suggestion? It *does* work for email messages, at least for things like a To: with key and a Cc: without, three To's: with keys, etc etc. Needs testing in real life for a bit, I'll report any scenario that doesn't work. Only problem is that it doesn't check for empty recipient anymore, so when you post in a newgroup, somehow the condition is true: (every lambda ... recipients) must return true for empty recipient list or something, need to investigate this. Anyway, a quick hack that works for me (proof is this message): (add-hook 'message-send-hook (lambda () (let* ((to-header (message-fetch-field "To")) (cc-header (message-fetch-field "Cc")) (bcc-header (message-fetch-field "Bcc")) (to (when (not (null to-header)) (substring to-header 3))) (cc (when (not (null cc-header)) (substring cc-header 3))) (bcc (when (not (null bcc-header)) (substring bcc-header 4))) (recipients (append (extract-addresses to) (extract-addresses cc) (extract-addresses bcc)))) (cond ((and (not (null recipients)) (every (lambda (rec) (or (pgg-lookup-key rec) (pgg-fetch-key pgg-default-keyserver-address rec))) recipients)) (mml-secure-message-encrypt-pgpmime)) (t (mml-secure-message-sign-pgpmime)))))) I'm sure you can enhance this again :-) Now thank you for the work in any case and whatever form this code is going to take, it's going to be very useful to me. Take care Eric