Mutt: the best text-based mail client ever existed Linux 09.03.2014

Mutt is mail client (Mail User Agent (MUA)) with text-based interface for *nix like systems. Initially mutt can only view mail messages. But last versions can retrive, send and filter mail.

I've been using mutt as my main email client for about five months. It's very useful for quick message check or reponse, more quickly then GMail's web access.

Installation

# under ArchLinux
yaourt -S mutt

# under Ubuntu
sudo apt-get install openssl mutt

Main configuration file can be located at ~/.muttrc or ~/.mutt/muttrc.

For IMAP it is enough to setup local folders (inbox, outbox, etc.) For POP3 it will be necessary to create local directory manually.

If you want to see mail box of somebody on local box you should execute this command

mutt -f /path/to/mail/john

General options

# vim ~/.muttrc

set realname = "Ivan Morgun"
set use_from = yes
set editor='vim -c "set spell spelllang=en_us,ru_ru"'
# see the headers when editing
# set edit_headers 
# sort by newest conversation first.
set sort = reverse-threads
set sort_aux = last-date-received

#confirmation skipping
set fast_reply=yes        # when replying, don't prompt for address
set include=yes           # include original text on reply?
set forward_quote=yes     # include original text on forward?
set delete=yes            # don't ask for delete confirmation

Options for IMAP (account at GMail)

# vim ~/.muttrc

set from = yourmail@gmail.com
set imap_user = yourmail@gmail.com
set imap_pass = secret
set smtp_url = smtp://yourmail@smtp.gmail.com:587/
set smtp_pass = secret
# don't let your firewall kill your idle connection
set imap_keepalive  = 900
# do not copy sent mail
set copy = no
set move = no 
set folder = imaps://imap.gmail.com:993
set spoolfile = +INBOX #or +[Gmail]/Important
set postponed = +[Gmail]/Drafts
# cache
set header_cache    = ~/.mutt/cache/headers
set message_cachedir    = ~/.mutt/cache/bodies
set certificate_file    = ~/.mutt/certificates

Options for POP3 (account at example.com)

We can use one of two mailbox types:

  • mbox - one file;
  • maildir - tree of folders (considered more rapid).

We will use getmail for mail receive

# under ArchLinux
yaourt -S getmail

Create necessary folders

mkdir -p ~/.mutt/cache
mkdir ~/.getmail
mkdir ~/.mail
mkdir -p ~/.mail/{cur,new,tmp}

Set options for mail receive

# vim ~/.getmail/getmailrc

[retriever]
type = SimplePOP3Retriever
server = mail.example.com
username = yourmail@example.com
port = 110
password = secret

[destination]
type = Maildir
path = ~/.mail/

[options]
read_all = False

Change access for privacy

chmod 700 ~/.getmail

Try to run getmail. If it runs without errors - we can add getmail to cron for periodic check.

# crontab -e 
*/10 * * * * /usr/bin/getmail

That will run getmail every 10 minutes.

Point mutt to folder with messages

vim ~/.mutt/muttrc

# POP3
set from = yourmail@example.com
set mbox_type=Maildir
set folder=$HOME/.mail
set spoolfile=+/
set header_cache=~/.mutt/cache

Options for SMTP (account at example.com)

vim ~/.mutt/muttrc

set my_pass='secret'
set my_user=yourmail@example.com
set smtp_url=smtp://$my_user:$my_pass@mail.example.com
set record="+sent"                 # where to store sent messages
set postponed="+postponed"         # where to store draft messages

You can cipher passwords with GPG, more about it.

Send message with attach from terminal

Send message with text

mutt -s "subject" recipient@server.com < ~/message.txt

Send message with text and file

mutt -s "subject" recipient@server.com -a file.zip < ~/message.txt

Aliases

Aliases is usefull for quick access to recipients.

# vim ~/.muttrc

set alias_file = "~/.mutt/aliases"
set sort_alias = alias
set reverse_alias = yes
source $alias_file

File with aliases

# vim ~/.mutt/aliases

alias mom mom@example.com

Useful shortcuts

  • m - compose mail;
  • r - reply to message;
  • f - forward mail;
  • t - change recipient email address;
  • c - change Cc address;
  • a - attach files as attachments;
  • y - send that email;
  • arrow up/down or j/k - move among messages not marked for deletion;
  • J/K - move among messages regardless of deletion mark;
  • / - search (in sender/subject if in list, or in message when you have one open);
  • enter - read message;
  • space (in message) - skip to next page of message;
  • S (in message) - skip quoted text;
  • T - toggle visibility of quoted text;
  • d - mark current message for deletion;
  • u - remove deletion marker;
  • o - sort;
  • q - quit mutt;
  • ctrl+g - stop current action (e.g. when it's asking a question).

Appearance

I prefer solarized colors for mutt with dark background.

Download theme

cd ~/.mutt/
git clone https://github.com/altercation/mutt-colors-solarized.git

Install theme

#vim ~/.muttrc

...
source ~/.mutt/mutt-colors-solarized/mutt-colors-solarized-dark-16.muttrc

Additional material