From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/3445 Path: news.gmane.org!not-for-mail From: Klaus Uhl Newsgroups: gmane.emacs.gnus.user Subject: Automatically sign/encrypt messages Date: Thu, 29 Jan 2004 18:31:07 +0100 Message-ID: <87n086ach0.fsf@ulm.my.lan> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: sea.gmane.org 1138669562 19013 80.91.229.2 (31 Jan 2006 01:06:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Jan 2006 01:06:02 +0000 (UTC) Original-X-From: nobody Tue Jan 17 17:32:14 2006 Original-Path: quimby.gnus.org!newsfeed.gazeta.pl!fu-berlin.de!uni-berlin.de!p5088e1af.dip0.t-ipconnect.DE!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-NNTP-Posting-Host: p5088e1af.dip0.t-ipconnect.de (80.136.225.175) Original-X-Trace: news.uni-berlin.de 1075397455 27492130 80.136.225.175 ([99401]) User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:U2NHjuE1+mrh0fUBnGJRTFummsI= Original-Xref: bridgekeeper.physik.uni-ulm.de gnus-emacs-gnus:3586 Original-Lines: 63 X-Gnus-Article-Number: 3586 Tue Jan 17 17:32:14 2006 Xref: news.gmane.org gmane.emacs.gnus.user:3445 Archived-At: --=-=-= Hi, I am not sure if this of interest for anybody here on this list nor if it was already discussed before. But as I did not find any information via a google search I post this here anyway. First I wanted gnus to automatically sign all sent messages. This was rather easy as a simple (add-hook gnus-message-setup-hook 'mml-secure-message-sign-pgpmime) did the job. But then I wanted to go one step further and not only sign but also encrypt all messages, at least if this is possible (i.e. if the recipient also uses PGP). The first attempt was the following: (add-hook gnus-message-setup-hook 'mml-secure-message-encrypt-pgpmime) But this _always_ tries to encrypt the message, even if the recipient has no PGP key. So I wrote the following hook: (add-hook 'message-send-hook (lambda () (let ((recipient (message-fetch-field "To"))) (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)))))) This works perfectly for me. Gnus encrypts the message if gpg already has the recipient's key in its keyring or if it can get the key from a keyserver. Otherwise the message is only signed. Maybe this helps someone. -- God is real ... \|/ ____ \|/ ... unless declared integer. "@'/ ,. \`@" \_| \__/ |_/ Mail me : news@u-h-l.de \__U_/ WWW : www.u-h-l.de PGP : 0x128F9DEC --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBAGUNfyaizchKPnewRAqm/AJ9XS1Lq3WPILHUHMDU94rI5Ih/kZgCgruMc zp5Tboh+jKLNJHl81wAxjbw= =BLpc -----END PGP SIGNATURE----- --=-=-=--