date: 2016-01-21 20:12:29
Title: Setting up Mutt with Gmail

Been a bit  sick lately, nowt particularly  serious, just mystery
absecces in my skull and subsequent blood poisonings, so I've had
some time to waste getting  around to the various computing tasks
that have been  waiting for the delivery of  Tuits^1. If you look
at your browser's  address bar, you'll see that this  site is now
being  delivered  over an  encrypted  connection,  because of  Ed
Snowden. Thanks to the  wonderful Lets Encrypt[1] project,  which
is an attempt to  make encrypted internet connections ubiquitous,
by getting  rid of payment, web  server configuration, validation
emails and  dealing with  expired certificates,  all in  order to
significantly lower the complexity  of setting up and maintaining
TLS encryption.

Setup was  a little  more complicated  than I'd  hoped, primarily
because I'm  using nginx as  my webserver, and  I intend to  do a
proper write up of this process soon.

All  that  messing  about  on the  command  line,  however,  just
reminded me how much I enjoy  that environment and how much of my
computing nowadays is carried  out in heavy-GUI environments. So,
I  decided as  an experiment  to see  how much  of my  day-to-day
computing I could accomplish on the command line.

First  target,  given  the  low-hanging fruit  nature  of  a  mad
experiment  done  when  you're  sick,  was  email,  specifically,
gmail. I've been using  gmail pretty much since  it was launched,
and find it suits my needs just fine for the most part. I've also
been using  two-factor authentication  on the  site since  it was
available, which naturally added some complexity to a switch to a
command line  client. I thought about  my needs, and I  decided I
definitely didn't want to keep a  massive local dump of my entire
gmail inbox, dating back to April 2004, on my shell account. This
effectively  means  that  more  modern  email  clients,  such  as
'sup[2], are  not  really an option.  I  did  consider  Alpine[3]
for  all of  about ten  seconds. Pine  was the  very first  email
client I  used, waaay back in  the days of VAX/VMS,  but a little
memory digging  reminded me that I  **hated** the interface. That
leaves me, in 2015, with Mutt[4].

As my internet shell is a debian box, installation of mutt was as
simple as an `aptitide install mutt`, although I admit I was more
than a little  shocked at the dependencies,  totalling some 65MiB
of  downloads. Once  that  was  done, I  created  some  necessary
folders for mutt, and created a config file

    mkdir -p ~/.mutt/cache/headers
    mkdir ~/.mutt/cache/bodies
    touch ~/.mutt/certificates
    touch ~/.mutt/muttrc

I   then   went  into   my   gmail   account,  and   created   an
application-specific  password  using  the  very  friendly  tools
Google provide for this specific purpose.

Then  editing  the `muttrc`  file  to  include my  gmail-specific
items:

 set ssl_starttls=yes
 set ssl_force_tls=yes
 set imap_user = 'my_user_name@gmail.com'
 set imap_pass = 'APP_PASSWORD'
 set from='my_user_name@gmail.com'
 set realname='My Name'
 set folder = imaps://imap.gmail.com/
 set spoolfile = imaps://imap.gmail.com/INBOX
 set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
 set header_cache = "~/.mutt/cache/headers"
 set message_cachedir = "~/.mutt/cache/bodies"
 set certificate_file = "~/.mutt/certificates"
 set smtp_url = 'smtps://my_user_name@gmail.com:APP_PASSWORD@smtp.gmail.com:465/'
 set move = no
 set imap_keepalive = 900
 set sort = reverse-date-received
 set sort_aux = reverse-last-date-received

The  last two  are  for the  purpose of  having  the most  recent
messages at the  top, the manner that gmail  handles new messages
and,  consequently, the  way I've  become used  to these  past 12
years.

Strange to  say, it worked  perfectly. Being back at  the command
line has  reminded me of the  sheer power of mutt,  and I've been
having  a  great  time  reacquainting  myself  with  the  MASSIVE
documentation for the  client. Next tasks are to  get gpg working
with it,  and to  have it  thread messages in  the same  way that
gmail does. I'd  also like to get  it to work using  my non-gmail
address, but that seems like it might be a tougher task, so falls
outside the parameters of my current experiment.

_______References_________________________________________________
[1]: https://letsencrypt.org/about
[2]: http://supmua.org
[3]: https://www.washington.edu/alpine/acquire/
[4]: http://www.mutt.org

_______Feetneet___________________________________________________
^1: Round, for the use of.