How to Use Mutt Email Client with Gmail

Going back to terminal based apps:
I’ve just recently gone back to the old-school ways of using the terminal instead of gui apps, as at work we administer a lot of Debian based servers remotely via ssh. My desktop now has one terminal open, with around 5-6 “Screens” with Mutt(email), Irssi(IRC), TwitVim(Identica), Elinks(Web) and a couple of spares for terminal/ssh work and editing with Vim.

Mutt is easier than you think:

Installing Mutt
To install mutt on Crunchbang/Squeeze:

sudo apt-get install mutt

Next, in the terminal, create these directories that mutt needs to cache message headers and bodies, and store certificates:

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

Now, create a basic Gmail-ready .muttrc
Choose your own text editor, I use Vim

vim .muttrc

And paste this basic gmail-ready config:
Once you have it pasted, edit the Gmail account details (everything you’ll need to alter is IN CAPITALS.) and save the file.
**Note** If you are in the UK you will need to use a slightly different config:HERE

**Edit** Darrin suggested that as your password is in plaintext, it may also be a good idea to encrypt your home directory as well for added security. (I’ll try to post a guide on single file encryption, directory encryption and entire drive/partition encryption at a later date) Thanks for the suggestion Derrin.

# Change the following six lines to match your Gmail account details
set imap_user = ""
set imap_pass = "PASSWORD"
set smtp_url = "smtp://"
set smtp_pass = "PASSWORD"
set from = ""
set realname = "YOUR NAME"

# Change the following line to a different editor you prefer.
set editor = "vim"

# Basic config, you can leave this as is
set folder = "imaps://"
set spoolfile = "+INBOX"
set imap_check_subscribed
set hostname =
set mail_check = 120
set timeout = 300
set imap_keepalive = 300
set postponed = "+[GMail]/Drafts"
set record = "+[GMail]/Sent Mail"
set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates
set move = no
set include
set sort = 'threads'
set sort_aux = 'reverse-last-date-received'
set auto_tag = yes
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc
alternative_order text/plain text/html *
auto_view text/html
bind editor complete-query
bind editor ^T complete
bind editor noop

# Gmail-style keyboard shortcuts
macro index,pager y "unset trash\n " "Gmail archive message"
macro index,pager d "set trash=\"imaps://[GMail]/Bin\"\n " "Gmail delete message"
macro index,pager gi "=INBOX" "Go to inbox"
macro index,pager ga "=[Gmail]/All Mail" "Go to all mail"
macro index,pager gs "=[Gmail]/Starred" "Go to starred messages"
macro index,pager gd "=[Gmail]/Drafts" "Go to drafts"

Start Using Mutt:
Run it from the terminal by simply typing mutt and hit “enter”. The first time you do this, you’ll be prompted to accept two SSL certificates from Google; press ‘a’ to always accept these certificates. You should now be greeted by your Gmail inbox.

Navigating, Reading and Sending Emails

Mutt is controlled from the keyboard and the following shortcuts will get you up and running:
For a more in depth list of commands and config features, either hit the “?” key in an open Mutt session or type “man mutt” in the terminal.

j to move down.
k to move up.
d to delete a message
y to archive one
gi to view your Inbox
ga to view All Mail
gd to view Drafts
gs to view Starred messages

And here are a few more that are particular to mutt:

t will mark a message
s will save one, or more
c lets you change to a different folder
/ lets you search the current folder

Sending Email with mutt
The basics look like this:

1. Type m (or r if you’re replying to a mail)
2. Enter the recipients email address; hit Return
3. Enter a subject; hit Return
4. Write your message.
5. Save it.
6. Type y, and your message will be sent.

Type q to quit mutt.


3 thoughts on “How to Use Mutt Email Client with Gmail

  1. This is really helpful; thank you for posting. Although there are numerous reasons why you might want to… I'd imagine that it would probably be wise for one to encrypt his/her /home directory since the gmail password is written in plain text in the .muttrc file.

    Thank you!

  2. Hi Darrin, Yes, that is a good suggestion.
    If you don't mind, i'll add it to the how-to and accredit the suggestion to you.



  3. Hi, great article. Thanks very much! I managed to set up my google apps email account with mutt. Everything else is working fine. But I'm having a problem with deleting emails. When I hit d is asks”
    Create ettrashtrash=”imaps://[GMail]/Bin”? ([yes]/no):

    When I say yes, it shows this message:

    ettrashtrash=”imaps://[GMail]/Bin”: No such file or directory (errno = 2)

    And deleting fails. Any idea how to get this done?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s