1

I'm trying to make mutt use a specific GPG key when sending mails to a specific recipient, much like "per-recipient rules" in OpenPGP / Enigmail. For example, if I want to send an email to coworker@company.com I want to encrypt it with the public key 0xDEADBEEF and when I send an email to loveydovey@home.net I want to encrypt it with some other public key 0xBA5EBA11.

To this end, I include the following lines in my ~/.mutt/muttrc file:

send-hook '~t ^coworker@company\.com$' 'set crypt_autoencrypt ; set crypt_autosign'
crypt-hook '~t ^coworker@company\.com$' '0xDEADBEEF'
send-hook '~t ^loveydovey@home\.net$' 'set crypt_autoencrypt ; set crypt_autosign'
crypt-hook '~t ^loveydovey@home\.net$' '0xBA5EBA11'

The send-hook works as expected, but I still always have to pick the key. How can I make mutt choose the key as defined by crypt-hook?

1

crypt-hook's pattern is a recipient, so remove ~t from the pattern, it's not needed:

crypt-hook '^coworker@company\.com$' '0xDEADBEEF'
  • 1
    Thanks! Is there any way to skip the confirmation question ('Use keyID ... ?') without any patches? – ryyst Jan 7 '14 at 10:25
  • Sorry, I don't know. – mkucharski Jan 14 '14 at 3:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.