Note: this wiki is no longer maintained. If you have any questions related to this wiki, please post them on the CrunchBang forums.

Translations of this page?:

Z-edit VARIOUS Mutt with Gmail/IMAP [OK?]

“All mail clients suck. This one just sucks less.” Michael Elkins, ca. 1995 This is mutt

Introduction

Mutt IS one of the best emailers around.

It's only disadvantage is that it is text based only, and that prevents many people from using it as their default email application. Mutt is however a very powerful email client with many features that are not included in other GUI emailclients.

This guide is focused on getting mutt up and running with your Gmail provider through its IMAP API and provides some keybindings to make the daily use easier.
We will look at how to recieve and sending email with mutt.

What mutt is NOT

Mutt is a Mail User Agent (MUA), and was written to view mail. It was not written to retrieve, send, or filter mail. It relies on external programs to do those tasks. But recently it has become possible to recieve and sending mails trough gmail.

Download and installation

Download and install mutt with this command

 sudo apt-get install mutt 


Additional applications that might be worth trying is urlview and muttprint, these are not associated with gmail though.

sudo apt-get install urlview muttprint muttprint-manual mutt-patched w3m
  • urlview - extracts urls from text and allows you to view in a program of your choice
  • muttprint - Printing those emails in a lovely format
  • muttprint-manual - The manual to tell you how to make those prints even prettier
  • mutt-patched - Folder view for mutt

These applications are not covered in this howto, but manpages are available once installed.

Configuration

Normally the default settings are fine to start with.

If you want to alter something, just put it in the configuration file that controls it all ~/.muttrc.

You can find the syntax for these configurations in the muttguide: http://wiki.mutt.org/index.cgi?MuttGuide

Setting up IMAP

Create ~/.muttrc in your preferred editor

$EDITOR ~/.muttrc

First we have to tell mutt who you are, put the following in your .muttrc

 
set from = "yourusername@gmail.com"
set realname = "Your Real Name"

Then mutt has to know where your gmail mailbox is and what your password is. You can safely put your password in here, we will cover this later.

set imap_user = "yourusername@gmail.com"
set imap_pass = "yourpassword"

Remember when running mutt for the first time, a certificate will be downloaded and you will be asked if you want to keep it. Just type Yes.

Setting up folders

The following lets mutt recognize your gmail folders (labels) and your local folders. Remember that sent messages goes to your Sent Mail folder on the gmail server pr. default, so no actions needs to be done here.

Remote folders

set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set trash = "imaps://imap.gmail.com/[Gmail]/Trash"

Local folders

Paste this in your ~/.muttrc

set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates

Now, create the 2 folders, the 3 lines above are referred to

mkdir .mutt
mkdir .mutt/cache

Setting up SMTP

Here you would specify the url and password to gmail's SMTP server.

set smtp_url = "smtp://yourusername@smtp.gmail.com:587/"
set smtp_pass = "yourpassword"

Special keybindings

The keybindings below shows mutt that pressing ie. “gi” (the letter g followed by the letter i) means “go to inbox”.

bind editor <space> noop
macro index gi "<change-folder>=INBOX<enter>" "Go to inbox"
macro index ga "<change-folder>=[Gmail]/All Mail<enter>" "Go to all mail"
macro index gs "<change-folder>=[Gmail]/Sent Mail<enter>" "Go to Sent Mail"
macro index gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"

Don't put spaces between

<change-folder>

the folder name as Mutt will complain that it cannot find the mailbox.

Secure your muttsession

These lines will help you preventing some minor annoyances.

set move = no  #Stop asking to "move read messages to mbox"!
set imap_keepalive = 900

Now save the file .muttrc in your /home directory. To be sure that only your username can access the file you'll have to give the file a proper permission.

Type this in your terminal

chmod 700 .muttrc

Some extra stuff

This is parts from my .muttrc (just to get you going). Please read the muttguide: http://wiki.mutt.org/index.cgi?MuttGuide for explanations!

# Header stuff
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc

ignore *
unignore from: date subject to cc
unignore x-mailing-list: posted-to:
unignore x-mailer:

# For better looks
set markers=no # don't put '+' at the beginning of wrapped lines
set pager_index_lines= 5 # how large is the index window?
set sort = 'threads'
set sort_aux = 'last-date-received'

# My Editor
set editor='vim + -c "set textwidth=72" -c "set wrap" -c "set nocp" -c "?^$"'

# My Rolodeck :)
set alias_file= ~/.mutt/aliases
set sort_alias= alias
set reverse_alias=yes
source $alias_file

Sorting Mail

* Added by griffen76

If you get large volumes of email, say from newsletters and the like, you can easily sort them in mutt with the following added to your .muttrc:

group -group adverts -rx (someone@nxxxx.com|Annoing@neccesary.com|contentupdates@somewhere.com|vienna@germany.com|info@netflix.com)

fcc-save-hook "%f adverts" "+[Gmail]/adverts"

The above will allow you from the Index view in mutt to hit:

  1. T <enter> %f adverts <enter>
    1. The above will tag all messages from the email addresses you declared in your 'group' statement
  2. ;s<enter>
    1. Will save all of those messages to the mailbox +[Gmail]/adverts

Customizing Mutt

Guides to get you started with using and customizing mutt :

i think i used this guide not too long ago to set this up. but not 100% sure. – rhowaldt

 
howto/howto_setup_mutt_with_gmail_imap.txt · Last modified: 2012/06/09 02:40 by griffen76
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported

Powered by DokuWiki. Hosted by Linode.
Copyright © 2010 CrunchBang Linux.
Proudly powered by Debian GNU/Linux.
Debian is a registered trademark of Software in the Public Interest, Inc.