Bookmark and Share

mutt with gmail, gpg encryption, and a signature

First step to setting up mutt with your gmail - make sure imap access is enabled in your gmail settings. Now let's configure the ~/.muttrc file. Here's an example basic setup (taken from shreevatsa.wordpress.com):

set smtp_url = "smtp://accountname@smtp.gmail.com:587/"
set smtp_pass = "XXX"
set from = "accountname@gmail.com"
set realname = "Your Name"

set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed="+[Gmail]/Drafts"

set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates

set move = no
set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed

ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc

Next let's add gpg support, encryption is good... Add this to your ~/.muttrc file (be sure to replace my key ID with your own):

set pgp_decode_command="gpg %?p?--passphrase-fd 0? --no-verbose --batch --output - %f"
set pgp_verify_command="gpg --no-verbose --batch --output - --verify %s %f"
set pgp_decrypt_command="gpg --passphrase-fd 0 --no-verbose --batch --output - %f"
set pgp_sign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --detach-sign --textmode %?a?-u %a? %f"
set pgp_clearsign_command="gpg --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
set pgp_encrypt_only_command="pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust --encrypt-to 0x7890D0B4 -- -r %r -- %f"
set pgp_encrypt_sign_command="pgpewrap gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust --encrypt-to 0x7890D0B4 -- -r %r -- %f"
set pgp_import_command="gpg --no-verbose --import -v %f"
set pgp_export_command="gpg --no-verbose --export --armor %r"
set pgp_verify_key_command="gpg --no-verbose --batch --fingerprint --check-sigs %r"
set pgp_list_pubring_command="gpg --no-verbose --batch --with-colons --list-keys %r"
set pgp_list_secring_command="gpg --no-verbose --batch --with-colons --list-secret-keys %r"
set pgp_autosign=yes
set pgp_sign_as=0x7890D0B4
set pgp_replyencrypt=yes
set pgp_timeout=1800
set pgp_good_sign="^gpg: Good signature from"

Here's some info on encrypting email.

And finally, let's add a custom signature. Create a file to store the signature in. I used ~/.signature

The text in this file will be your sig. Add a line referencing the file in your ~/.muttrc file:

set signature="~/.signature"

Enjoy using gmail in your terminal!

  1. gravatar

    # by Unknown - January 1, 2014 at 9:39 AM

    This is completely complex and confusing for me. I am a non technical person and do not posses any knowledge about the point you have cleared above.
    digital certificate

  2. gravatar

    # by Sharar Ravitz - January 1, 2014 at 6:50 PM

    Can you be more detailed on where you are stuck?