Monday, June 25, 2012

mutt /w IMAP & GPG on OS X

This is just a short little blog on getting ‘mutt’ going with GPG support on a Mac OS X machine. Started off with me having issues getting to my mail at customer sites and the over all lack of a good PGP option on my iPhone.

This seemed like a simple option. (Mostly this post is so I can recall how I set things up for the next time I need to do it in the .muttrc file)



The first thing your going to want / need is Xcode on your Mac so you have GCC -
*this is free in the App Store*

After that d/l and install Mac ports:
http://www.macports.org/

then run the following command

sudo port install  mutt-devel +imap +ssl +headercache +gnupg +smtp +sasl +trash

Now you will need to build a .muttrc file for your home dir; mine looks like this, you will need to edit username, hostname, and the PGP key 0x00000000.

----

set imap_user = 'username'
set spoolfile = imaps://username@hostname:993/INBOX
set folder = imaps://hostname:993
set record="imaps://hostname/Sent"
set postponed="imaps://hostname/Drafts"
set certificate_file=~/.mutt/certificates
set header_cache=~/.mutt/cache

set smtp_url = "smtp://username@hostname:587/"
set from = "emailaddress@yourhost.com"
set realname = "Full Name"

# activate TLS if available on the server
set ssl_starttls=yes
# always use SSL when connecting to a server
set ssl_force_tls=yes

set sort=threads

# HTML emails
auto_view text/html

bind index G imap-fetch-mail
bind pager G imap-fetch-mail

set mail_check=30
set timeout=60
set editor='pico -r 72'

# COLORS
color attachment brightmagenta black
color error brightwhite red # errors yell at you in red
color hdrdefault red black # headers
color indicator brightyellow magenta # currently selected message
color markers brightcyan black # the + for wrapped pager lines
color message brightcyan black # informational messages, not mail
color normal white black # plain text
color quoted green black # quoted text
color search brightgreen black # hilite search patterns in the pager
color signature red black # signature (after "-- ") is red
color status brightyellow blue # status bar is yellow *on blue*
color tilde blue black # ~'s after message body
color tree red black # thread tree in index menu is magenta
color signature brightred black
color underline yellow black
color header cyan black ^(From|Subject): # Important headers
color body magenta black "(ftp|http)://[^ ]+" # picks up URLs
color body magenta black [-a-z_0-9.]+@[-a-z_0-9.]+

# Coloring quoted text - coloring the first 7 levels:
color quoted cyan black
color quoted1 yellow black
color quoted2 red black
color quoted3 green black
color quoted4 cyan black
color quoted5 yellow black
color quoted6 red black
color quoted7 green black

# Colorize smileys: :-) ;-) :-/ :-(
color body yellow black "[;:]-[)/(|]"
color body yellow black "[;:][)/(|]"
color body green black "[[:alpha:]]\+://[^ ]*"

color index brightyellow black ~N # New
color index yellow black ~O # Old
color index magenta black ~F
color index blue black ~T
color index red black ~D

#GPG
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 0x00000000 -- -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 0x00000000 -- -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"

# specify the uid to use when encrypting/signing
set pgp_sign_as=0x00000000

# this set the number of seconds to keep in memory the passpharse used to encrypt/sign
# the more the less secure it will be
set pgp_timeout=60

# it's a regexp used against the GPG output: if it matches some line of the output
# then mutt considers the message a good signed one (ignoring the GPG exit code)
set pgp_good_sign="^gpg: Good signature from"

# mutt uses by default PGP/GPG to sign/encrypt messages
# if you want to use S-mime instead set the smime_is_default variable to yes

# automatically sign all outcoming messages
#set crypt_autosign
# sign only replies to signed messages
#set crypt_replysign

# automatically encrypt outcoming messages
#set crypt_autoencrypt=yes
# encrypt only replies to signed messages
#set crypt_replyencrypt=yes
# encrypt and sign replies to encrypted messages
#set crypt_replysignencrypted=yes

# automatically verify the sign of a message when opened
#set crypt_verify_sig=yes


---
Note that you will also need to setup gpg to work with your keys or make keys.

At this point you are good to go, just run ‘mutt’ from the command-line and your rockin.

cheers

JSN

1 comment:

  1. Can you install Mutt with Homebrew? Homebrew is a lot easier to work with than MacPorts imo.

    ReplyDelete