From: Eric Simon <erik.simon@unine.ch>
Subject: Re: Automatically sign/encrypt messages
Date: Wed, 04 Feb 2004 17:33:08 +0100 [thread overview]
Message-ID: <8765emerej.fsf@pc70-23.unine.ch> (raw)
In-Reply-To: <87n086ach0.fsf@ulm.my.lan>
[-- Attachment #1: Type: text/plain, Size: 1591 bytes --]
Klaus Uhl <news@u-h-l.de> writes:
> (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))))))
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...
Anyway:
(add-hook
'message-send-hook
(lambda ()
(let* ((recipient (message-fetch-field "To"))
(recid (if (not (null recipient))
(car (mail-header-parse-address recipient)))))
(cond ((and (not (null recipient))
(or
(pgg-lookup-key recid)
(pgg-fetch-key pgg-default-keyserver-address recid))
)
(mml-secure-message-encrypt-pgpmime))
(t
(mml-secure-message-sign-pgpmime))))))
The first (if (not (null recipient)) is to avoid trying to take the car
of something bad, dunno if needed really, quite ugly, but safer in my
opinion.
Cheers
Eric
[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]
next prev parent reply other threads:[~2004-02-04 16:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-29 17:31 Klaus Uhl
2004-01-30 19:06 ` Ted Zlatanov
[not found] ` <87ptd0jsqv.fsf@u-h-l.de>
2004-02-02 20:27 ` Ted Zlatanov
2014-05-15 21:41 ` Peter Münster
2004-02-04 16:33 ` Eric Simon [this message]
2004-02-04 16:51 ` Klaus Uhl
[not found] ` <87znby7oby.fsf@pc70-23.unine.ch>
[not found] ` <87r7xar7i9.fsf@ulm.my.lan>
2004-02-05 18:37 ` Eric Simon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8765emerej.fsf@pc70-23.unine.ch \
--to=erik.simon@unine.ch \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).