Mutt and Gmail

A RECIPE IS A LIST of instructions, just that. It’s not necessarily about food or edible goods; it can be oh so much more. As this is a blog not just about the consumption of meals and drinking, but also time and energy, it seems fair that I also document the other ways in which I choose to profligately squander the short time I will walk the earth.

I quite like the free email service Google provides. I also have a soft spot in my heart for using computers to do things in ways that aren’t entirely in keeping with the browser-heavy experience of those one generation younger than me. How can I reconcile these two?

Mutt screenshot

Gmail and Mutt

Mutt is a very simple but very customisable mail user agent (MUA) which does IMAP mail pretty efficiently, and these days does SMTP pretty well too. Hooray for common sense! Get yourself the latest version and put a variation on the following into your .muttrc:

mailboxes imaps://username@gmail.com@imap.gmail.com:993/

I’ve got a couple of these lines for each of email addresses I check, and with a series of them I can switch between IMAP mailboxes pressing y.

Then, to give details for Gmail using folder-hook and account-hook:

account-hook imaps://liamvhogan@gmail.com@imap.gmail.com:993/ ' \
set imap_user="username@gmail.com" \
imap_pass="password"
folder=imaps://username@gmail.com@imap.gmail.com:993/ '
folder-hook imaps://username@gmail.com@imap.gmail.com:993/ ' \
set from="username@gmail.com" \
spoolfile="imaps://username@gmail.com@imap.gmail.com:993/INBOX" \
postponed="imaps://username@gmail.com@imap.gmail.com:993/[Gmail]/Drafts" \
smtp_url="smtp://username@gmail.com@smtp.gmail.com:587" \
smtp_pass="password" ' 

The really nice thing I find about Gmail is the contacts management that also goes to my telephone, and being able to add people’s details automatically for later reference, and the ability to autocomplete when it comes time to send them mail. Can you have that in a text-based mail user client that’s nearly old enough to vote in Australia? With this very convenient perl script, yes you can. As per the instructions on that page, set up a .netrc file with Google’s details for the script to access, then into .muttrc put the following:

set query_command="goobook query '%s'" 
bind editor <Tab> complete-query
macro index,pager a "<pipe-message>goobook add<return>" "add the sender address to Google contacts"

And you have an entirely text-based, address-autocompleting, way of getting at your mail on Gmail. Isn’t that just what you wanted?

---

/

Commenting is closed for this article.