HOWTO: Mutt

Forum rules
Share your brain ;)
User avatar
slartie
Grump
Posts: 416
Joined: Tue Jun 18, 2013 12:35 pm
Location: Denmark
Contact:

HOWTO: Mutt

Unread post by slartie » Thu Sep 05, 2013 10:45 am

..._____          __    __   
  /     \  __ ___/  |__/  |_    
 /  \ /  \|  |  \   __\   __\     A guide to getting started with the Mutt
/    Y    \  |  /|  |  |  |       E-Mail Client.
\____|__  /____/ |__|  |__|  
        \/                   

-Todo:
  * Emacs specific options
  * VIM specific options
  * Using GPG
  * Mutt-patched
  * Theming Mutt

===============================================================================
INTRO ^
===============================================================================
     When Ray Tomlinson sent the first email from one DEC-10 to another DEC-10
     in 1971, the world was about to become a very different and way more
     exciting place.

     Email has been with us ever since. It may have been pushed a bit into the
     background to make room for text messaging, social network communication
     and microblog services, but email is still going strong.

     When you want to send an email, you have to use a client of some
     sort. There are a lot to choose from, but if you want to cut away the
     cruft and just get the job done, there's no better option than a text
     based one.

     Mutt is such a client, and it impresses by doing one thing slightly less
     than most other clients out there, namely...

     Sucking.

     This guide will take you through the installation of Mutt, the basic setup
     for IMAP (in this case, Gmail) and a selection of configuration tweaks
     that makes life just a little bit easier.

     Based on feedback, I will expand this guide further in the future.

===============================================================================
CONTENTS ^
===============================================================================
     INTRO                       (You just came from there)
     CONTENTS	 	         (You are here)
     INSTALLATION                (APT-GET IT)
     BASIC SETUP                 (Say hi to Gmail)
     CUSTOMIZE                   (Making it better)
     RESOURCES                   ()
     ABOUT                       (About the author)
     LICENSE                     (Because we all need one)

===============================================================================
INSTALLATION ^                                                       APT-GET IT
===============================================================================
     Before you can get any emailing done, you have to get Mutt installed.

     ~% apt-get install mutt

     What? You expected more?

     Most (if not all) current GNU/Linux distros have Mutt sitting in their
     repositories. Replace 'apt-get install' with your equivalent emerge,
     portage, yum, pacman (or whatever you use) command.
     
===============================================================================
BASIC SETUP ^                                                   SAY HI TO GMAIL
===============================================================================
     Every part of Mutt is configured with an .rc file, namely .muttrc

     ~% touch ~/.muttrc

     Open .muttrc with your favorite editor, and let's start putting a few
     basics in there.

     ################################
     # IMAP + SMTP + NAME information
     ################################
     set imap_user = "[email protected]"
     set imap_pass = "YourPassword"
     set smtp_url = "smtp://[email protected]:587/"
     set smtp_pass = "YourPassword"
     set from = "[email protected]"
     set realname = "Your Name"
     ################################

     The above should be fairly self explanatory, but we're basically telling
     Mutt what credentials to use when authenticating with the IMAP and SMTP
     protocol, as well as telling it what our name is.

     Replace UserName with your Google account username
     Replace YourPassword with your Google account password.
     Replace Your Name with your real name, or whatever you like.

     If you are using 2-step verification with Google, be sure to create an
     application password for Mutt.

     Go to https://security.google.com/settings/security for details.

     Once you've figured out that password business, it's time to move on to
     the next bit for the basic configuration.

     ###########################
     # SETTING SENSIBLE DEFAULTS
     ###########################
     set folder = "imaps://imap.gmail.com:993"
     set spoolfile = "+INBOX"
     set postponed = "+[GMail]/Drafts"
     set imap_check_subscribed
     set hostname = gmail.com
     set mail_check = 120
     set timeout = 300
     set imap_keepalive = 300
     ###########################

     Here we're telling Mutt where to find the mail folders, which folder to
     open by default, where to put drafts, how often to check for new mail and
     so on. You should never have to change these defaults.

     As with the previous settings we put in .muttrc, every configuration
     option is self explanatory.

     imap_check_subscribed tells mutt to automatically check for new mail.

     With those two chunks of configuration settings, you can start using mutt,
     and be merry. But, we can't stop there.

===============================================================================
CUSTOMIZE ^                                                    MAKING IT BETTER
===============================================================================
     When working with IMAP folders, it's always nice to be able to navigate
     around in them quickly, so let's make some macros to make that easier, as
     well as making message archiving and deletion a breeze.

     ########################
     # MACROS FOR GMAIL TASKS
     ########################
     macro index,pager y "<enter-command>unset trash\n <delete-message>" "Gmail archive message"
     macro index,pager d "<enter-command>set trash=\"imaps://imap.googlemail.com/[GMail]/Bin\"\n <delete-message>" "Gmail delete message"
     macro index,pager gi "<change-folder>=INBOX<enter>" "Go to inbox"
     macro index,pager ga "<change-folder>=[Gmail]/All<quote-char> Mail<enter>" "Go to all mail"
     macro index,pager gs "<change-folder>=[Gmail]/Starred<enter>" "Go to starred messages"
     macro index,pager gd "<change-folder>=[Gmail]/Drafts<enter>" "Go to drafts"
     ########################

     Each macro is set with a keybinding followed by a string of commands and
     the name for the macro.

     When checking email, I find it helpful that the newest emails are the ones
     at the top of the pile. Also, most of the time, they're part of an ongoing
     conversation. So I like my mail sorted as such.

     ##################################
     # SORTING BY THREADS, NEWEST FIRST
     ##################################
     set sort = 'threads'
     set sort_aux = 'reverse-last-date-received'
     ##################################

     Here we set the sorting to be done by threads and make sure the newest
     ones go to the top.

     An email will contain a lot of header information, most of which we don't
     really care about. So let's get rid of that.

     ###############################
     # HIDE MOST OF THE EMAIL HEADER
     ###############################
     ignore *
     unignore from: date subject to cc
     unignore x-mailing-list: posted-to:
     unignore x-mailer:
     hdr_order Date From To Cc
     ###############################

     We start by ignoring everything, followed by a group of exceptions. After
     that we tell Mutt in which order we'd like to see the header information.

     Finally there's a pile of settings that I don't really want to put in a
     section of their own, because they really aren't related to anything, but
     still nice to have.

     ########################
     # MISCELLANEOUS SETTINGS 
     ########################
     set markers = no                          # We don't need an indicator to see that a line is wrapped
     set pager_index_lines = 5                 # A mini index to tell us where we're at in the mailbox folder when reading emails
     set header_cache=~/.mutt/cache/headers    # Cache headers for faster access
     set message_cachedir=~/.mutt/cache/bodies # Cache bodies for faster access
     set certificate_file=~/.mutt/certificates # Tell Mutt where to save certs
     set move = no                             # Don't move messages after reading them
     set include                               # Include original message in reply
     set auto_tag = yes                        # Because it just makes sense
     unset record                              # With Gmail all mail goes to the same place
     alternative_order text/plain text/html *  # We'd like to see plain text before anything else
     auto_view text/html                       # Use lynx/links/etc. to dump html to text
     ########################

===============================================================================
RESOURCES ^                                                     ALL THINGS MUTT
===============================================================================
     Mutt          [ http://www.mutt.org/ ]
     Mutt Manual   [ http://www.mutt.org/doc/manual.txt ]

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: HOWTO: Mutt

Unread post by dkeg » Thu Sep 05, 2013 1:16 pm

@slartie, thanks for putting this together. I mainly use MUTT to access my gmail. Good write up. just to note, keeping your password blank, you'll be required to enter each time you start mutt.

Work hard; Complain less

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: HOWTO: Mutt

Unread post by GekkoP » Thu Sep 05, 2013 2:35 pm

Thanks a lot for this one.
I got two accounts set. Now the only thing left is set another account that has the same IMAP as one of the two I already set.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Mutt

Unread post by machinebacon » Sat Sep 07, 2013 5:24 am

Thanks slartie for the HOWTO. Followed it for a test (copypasta) and it works straight out of the tin. Will recommend ;)
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: HOWTO: Mutt

Unread post by dkeg » Sat Sep 07, 2013 2:18 pm

since I mainly use VIM, I'll add some things I find useful

Code: Select all

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

Code: Select all

# Vim like keybinds
bind pager j next-line
bind pager k previous-line
Not really VIM specific, but

Code: Select all

# Use abook with Mutt
set query_command="abook --mutt-query '%s'"
macro index a	"|abook --add-email\n" 'add sender to abook'
macro pager a	"|abook --add-email\n" 'add sender to abook'

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Mutt

Unread post by machinebacon » Sat Sep 07, 2013 2:29 pm

Wow, I love the abook idea, great!

Thanks!
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: HOWTO: Mutt

Unread post by GekkoP » Thu Sep 12, 2013 7:50 am

GekkoP wrote:Thanks a lot for this one.
I got two accounts set. Now the only thing left is set another account that has the same IMAP as one of the two I already set.
Solved. Finally three mail accounts working on Mutt. I'm happy. Now I got to check this abook thingy.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: HOWTO: Mutt

Unread post by GekkoP » Thu Oct 31, 2013 5:29 pm

Don't know if this can be of any help, but I used to have infamous "TLS packet with unexpected length was received" error, causing Mutt to crash. So what I did was recompiling it with openssl support instead of gnutls to see if this makes any difference at all.
Basically this is what I did after downloading latest Mutt from its official website:

Code: Select all

sudo apt-get build-dep mutt
sudo apt-get install openssl libsasl2-modules libssl-dev libssl1.0.0
tar xzvf mutt-1.5.22.tar.gz 
./configure --enable-pop --enable-imap --enable-smtp --with-ssl --enable-hcache --with-gss --with-sasl --enable-debug --enable-gpgme
make 
sudo make install
No error so far, hope this can help anybody with the same issue.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: HOWTO: Mutt

Unread post by dkeg » Sat Nov 23, 2013 2:55 pm

webpage found so possibly could be helpful. I saw bones article link today and when reading through that came across this

http://dev.mutt.org/trac/wiki/MuttFaq

and of course our very own wiki has good links

Work hard; Complain less

User avatar
slartie
Grump
Posts: 416
Joined: Tue Jun 18, 2013 12:35 pm
Location: Denmark
Contact:

Re: HOWTO: Mutt

Unread post by slartie » Thu Dec 05, 2013 9:24 am

There's a whole section about ways to bend mutt into shape with recompilation I really want to touch on, but looking for work has been keeping me extremely busy. I am however, not completely dead. Just hovering in the shadows.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Mutt

Unread post by machinebacon » Thu Dec 05, 2013 10:35 am

^ And what's that funny smell? :D
..gnutella..

User avatar
slartie
Grump
Posts: 416
Joined: Tue Jun 18, 2013 12:35 pm
Location: Denmark
Contact:

Re: HOWTO: Mutt

Unread post by slartie » Thu Dec 05, 2013 10:52 am

Feces, lad. Lots and lots of feces.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: HOWTO: Mutt

Unread post by dkeg » Thu Dec 12, 2013 2:23 pm

set up mutt sidebar, mutt-patched required. And of course setting up mailboxes. Some of this I had, some I picked up from Arch Wiki.

Code: Select all

# Folders in side pane

set sidebar_visible=yes
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'

# Ctrl-n, Ctrl-p to select next, previous folder.
# Ctrl-o to open selected folder.

bind index,pager \CP sidebar-prev
bind index,pager \CN sidebar-next
bind index,pager \CO sidebar-open

# Trouble with truncated names
set sidebar_shortpath = yes
set sidebar_sort

set imap_check_subscribed
scrot
mutt_sidebar.png
mutt_sidebar.png (8.68 KiB) Viewed 7656 times

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Mutt

Unread post by machinebacon » Thu Dec 12, 2013 8:00 pm

i love that so much!! thanks drew :)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: HOWTO: Mutt

Unread post by GekkoP » Fri Dec 20, 2013 5:34 pm

Smooth trick with the sidebar there!
@slartie: hope you find the time to properly cover mutt compilation. Even with my recompiling, it sometimes still crashes.

User avatar
slartie
Grump
Posts: 416
Joined: Tue Jun 18, 2013 12:35 pm
Location: Denmark
Contact:

Re: HOWTO: Mutt

Unread post by slartie » Fri Dec 20, 2013 9:07 pm

I haven't yet managed to crash Mutt. You must be doing something wrong :)

The sidebar patch has been working well for me as well.

Admittedly I haven't done much experimenting with recompiling mutt since the mid 90s, but it might be fun to revisit that.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Mutt

Unread post by machinebacon » Sat Dec 21, 2013 7:33 pm

Where the fuck are the newsletters? ;)
..gnutella..

User avatar
slartie
Grump
Posts: 416
Joined: Tue Jun 18, 2013 12:35 pm
Location: Denmark
Contact:

Re: HOWTO: Mutt

Unread post by slartie » Sun Dec 22, 2013 10:50 pm

soon (tm)

User avatar
ricardo
Virgin
Posts: 9
Joined: Wed Feb 26, 2014 11:42 pm

Re: HOWTO: Mutt

Unread post by ricardo » Wed Mar 12, 2014 8:44 pm

does anyone knows if mutt can read claws-mail's TAGS (labels)?

i've been using claws but i am configuring mutt it's working already, but lacks a lot of features that i want.

on claws i made some tags that i attribute to several messages, can mutt read those tags?
it's easier to search messages using some tags.

thanks!

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: HOWTO: Mutt

Unread post by machinebacon » Thu Mar 13, 2014 5:54 am

Good question. Isn't it that actually the tags are set in IMAP, as folders? Or are these per-message tags? I never heard of them, though :) Tagging (as in moving topic-related mails) I do with filters and then into IMAP folders, and I think this is the way it works, at least in gmail.
..gnutella..

Post Reply