8.1. Encrypted Mail with Emacs
Problem
You use an Emacs mailer (vm, rmail, etc.) and want to send and receive encrypted email messages.
Solution
Use mailcrypt.el with GnuPG:
~/.emacs:
(load-library "mailcrypt")
(mc-setversion "gpg")
Then open a mail buffer, and use any Mailcrypt functions or variables as desired:
-
mc-encrypt
Encrypt the mail message in the current buffer
-
mc-decrypt
Decrypt the mail message in the current buffer
-
mc-sign
Sign the mail message in the current buffer
-
mc-verify
Verify the signature of the mail message in the current buffer
-
mc-insert-public-key
Insert your public key, in ASCII format, into the current buffer
...and many more.
Discussion
Mailcrypt is an Emacs package for encrypting, decrypting, and cryptographically signing email messages. Once you have installed mailcrypt.el in your Emacs load path, e.g., by installing it in /usr/share/emacs/site-lisp, and loaded and configured it in your ~/.emacs file:
(load-library "mailcrypt") (mc-setversion "gpg")
compose a mail message in your favorite Emacs-based mailer. When done writing the message, invoke:
M-x mc-encrypt
(or select the Encrypt function from the Mailcrypt menu). You’ll be prompted for the recipient, whose public key must be on your GnuPG keyring:
Recipients: jones@example.com
and then asked whether you want to sign the message, which is an optional step and requires your GnuPG passphrase.
Sign the message? (y or n)
Then voilà, your message becomes GnuPG-encrypted for that recipient:
-----BEGIN PGP MESSAGE----- ...
Get Linux Security Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.