Eric Simon writes: > Nice indeed. Been using it today. Then I noticed sometimes it's not able > to find the key in my ring or on the server because (message-fetch-field > "To") returns the whole header. There is a function to parse a string > and get a pair email/name: mail-header-parse-address, so I thought > getting only the actual address would be better. > > So below is a slightly modified version that's been working nice for me > for the past... 2 hours or so? Oh, not exactly, one friend had a public > key published but didn't use encryption anymore and didn't have the > secret counterpart, so he complained I was using cryptography with > him... > > (let* ((recipient (message-fetch-field "To")) > (recid (if (not (null recipient)) > (car (mail-header-parse-address recipient))))) You should probably set recid to nil if recipient is nil and use recid instead of recipient in the cond below. > (cond ((and (not (null recipient)) I rewrote the hook this way and changed the variable names to name what they actually hold: (add-hook 'message-send-hook (lambda () (let* ((to-header (message-fetch-field "To")) (recipient (if (null to-header) nil (car (mail-header-parse-address to-header))))) (cond ((and (not (null recipient)) (or (pgg-lookup-key recipient) (pgg-fetch-key pgg-default-keyserver-address recipient))) (mml-secure-message-encrypt-pgpmime)) (t (mml-secure-message-sign-pgpmime)))))) Klaus -- God is real ... \|/ ____ \|/ ... unless declared integer. "@'/ ,. \`@" \_| \__/ |_/ Mail me : news@u-h-l.de \__U_/ WWW : www.u-h-l.de PGP : 0x128F9DEC