Mutt and Gmail

This .muttrc works quite good with Gmail through IMAP protocol.
Change all references to my.home.my.castle, imap password and PGP key number.

S/MIME is not used here. Requires configuration.

ToDo: in Sent view (formerly index) recipient should be listed, not sender (me).

Mutt address book used in this muttrc is described in Mutt query command on this blog.

set config_charset=utf-8

set spoolfile = imaps://imap.gmail.com:993/INBOX
set imap_user = 'my.home.my.castle@gmail.com'
set imap_pass = 'verystrongpassword'
set folder = imaps://imap.gmail.com:993
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set imap_check_subscribed="yes"
set imap_list_subscribed="yes"
# Inbox is what you can open using
set mbox = "imaps://imap.gmail.com/INBOX"
set smtp_url="smtp://my.home.my.castle@smtp.gmail.com:587/"

# There are many tweaks to suit index view to your needs
#set index_format = "%3C %Z %[%b %d %H:%M] - %-22.22L (%3l) %s"
folder-hook . 'set index_format="%Z %{%b %d} %-15.15F (%4l) %s"'
folder-hook . 'set sort = threads'
folder-hook "imaps://imap.gmail.com/[Gmail]/Sent Mail" 'set sort=date-sent'

set sendmail="/usr/sbin/sendmail -oem -oi"

# Customize it, if you use many different .muttrc* files
set header_cache="~/.mutt/gmail_header_cache"
set message_cachedir="~/.mutt"
set certificate_file="~/.mutt/certs"
set tmpdir="~/.mutt/tmp"

ignore *
unignore Date: From: To: Cc: Bcc: Reply-To: Subject:
set folder_format="%N %-8.8u %8s %d %N %f"
set forward_format = "Fwd: %s"

set weed = yes
set move = no
set pager_index_lines = 0
set edit_headers = yes

set pager_context = 4
set pager_stop = yes
set nomarkers

set use_from = yes
# Change to your real/fake name
set realname = "Artur Kaminski"
set envelope_from = yes
my_hdr From: Artur Kaminski

# Simple address book described in another post on my blog
set query_command="~/.mutt/addgrep.sh '%s'"

# Wrap at 72nd character
set editor="/usr/bin/vim +11 -c 'set tw=72 ft=mail noautoindent'"
auto_view text/html

set mail_check = 5
set timeout = 1
set quit = ask-yes

subscribe ".*@lists.debian.org"
subscribe ".*@postgresql.org"
#set record="+[Gmail]/Sent Mail"
set postponed="+[Gmail]/Drafts"
set nomark_old

send-hook . 'set signature=~/.mutt/gmail.sig'
set status_format="%v: %f (%s) [%M/%m] %l [N=%n, X=%t,post=%p]"

#==== GnuPG ====
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 0x1D0AF57B -- -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 0x1D0AF57B -- -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_getkeys_command="gpg --no-verbose --recv-keys %r"
set pgp_autosign=yes
set pgp_sign_as=0x1D0AF57B
set pgp_replyencrypt=yes
set pgp_timeout=1800
set pgp_good_sign="^gpg: Good signature from"
set pgp_auto_decode=yes

#==== S/MIME ====
# -*-muttrc-*-
## The following options are only available if you have
## compiled in S/MIME support

# If you compiled mutt with support for both PGP and S/MIME, PGP
# will be the default method unless the following option is set
#set smime_is_default
# Uncoment this if you don't want to set labels for certificates you add.
# unset smime_ask_cert_label

# Passphrase expiration
set smime_timeout=300

# Global crypto options -- these affect PGP operations as well.
set crypt_autosign = yes
set crypt_replyencrypt = yes
set crypt_replysign = yes
set crypt_replysignencrypted = yes
set crypt_verify_sig = yes

# Section A: Key Management.

# The (default) keyfile for signing/decrypting. Uncomment the following
# line and replace the keyid with your own.
set smime_default_key="12345678.0"

# Uncommen to make mutt ask what key to use when trying to decrypt a message.
# It will use the default key above (if that was set) else.
# unset smime_decrypt_use_default_key

# Path to a file or directory with trusted certificates
set smime_ca_location="~/.smime/ca-bundle.crt"

# Path to where all known certificates go. (must exist!)
set smime_certificates="~/.smime/certificates"

# Path to where all private keys go. (must exist!)
set smime_keys="~/.smime/keys"

# These are used to extract a certificate from a message.
# First generate a PKCS#7 structure from the message.
set smime_pk7out_command="openssl smime -verify -in %f -noverify -pk7out"
# Extract the included certificate(s) from a PKCS#7 structure.
set smime_get_cert_command="openssl pkcs7 -print_certs -in %f"
# Extract the signer's certificate only from a S/MIME signature (sender verification)
set smime_get_signer_cert_command="openssl smime -verify -in %f -noverify -signer %c -out /dev/null"
# This is used to get the email address the certificate was issued to.
set smime_get_cert_email_command="openssl x509 -in %f -noout -email"
# Add a certificate to the database using smime_keys.
set smime_import_cert_command="smime_keys add_cert %f"

# Sction B: Outgoing messages

# Algorithm to use for encryption.
# valid choices are rc2-40, rc2-64, rc2-128, des, des3
set smime_encrypt_with="des3"
# Encrypt a message. Input file is a MIME entity.
set smime_encrypt_command="openssl smime -encrypt -%a -outform DER -in %f %c"
# Sign.
set smime_sign_command="openssl smime -sign -signer %c -inkey %k -passin stdin -in %f -certfile %i -outform DER"

#Section C: Incoming messages

# Decrypt a message. Output is a MIME entity.
set smime_decrypt_command="openssl smime -decrypt -passin stdin -inform DER -in %f -inkey %k -recip %c"
# Verify a signature of type multipart/signed
set smime_verify_command="openssl smime -verify -inform DER -in %s %C -content %f"
# Verify a signature of type application/x-pkcs7-mime
set smime_verify_opaque_command="openssl smime -verify -inform DER -in %s %C"

# Section D: Alternatives

# Sign. If you wish to NOT include the certificate your CA used in signing
# your public key, use this command instead.
# set smime_sign_command="openssl smime -sign -signer %c -inkey %k -passin stdin -in %f -outform DER"
# In order to verify the signature only and skip checking the certificate chain:
# set smime_verify_command="openssl smime -verify -inform DER -in %s -content %f -noverify"
# set smime_verify_opaque_command="openssl smime -verify -inform DER -in %s -noverify"

# Colour themes
# Available at
# http://www.xs4all.nl/~hanb/configs/dot-mutt/themes/
#source ~/.mutt/themes/blah
source ~/.mutt/themes/color
#source ~/.mutt/themes/comidia
#source ~/.mutt/themes/default
#source ~/.mutt/themes/ice
#source ~/.mutt/themes/lazygenestheme
#source ~/.mutt/themes/openbsd
#source ~/.mutt/themes/rosenfeldstheme
#source ~/.mutt/themes/tomastheme
#source ~/.mutt/themes/trans-blue
#source ~/.mutt/themes/trans-cyan
#source ~/.mutt/themes/trans-gen ### Themimg Engine :-)
#source ~/.mutt/themes/trans-green
#source ~/.mutt/themes/trans-magenta
#source ~/.mutt/themes/trans-red
#source ~/.mutt/themes/trans-yellow

No comments: