Absurd: Multi-account Mutt

20201104

Mutt is a mail user agent. It's an old one. It doesn't have a GUI.

The configuration of Mutt is the thing that normall turns people off about it. This is completely understandable. If you are not radically familiar with email in general, many of the options can seem esoteric, and more importantly I do not think that there is a place out there that lists all of them with simple human language descriptions. Despite these shortcomings, I use Mutt. Always have.

Let's get this party started. I have posted configs in the past for using mutt with one email account. What about when you have two? Five?

Well, you will use multiple files. In your muttrc, you will have something like this to setup the common stuff between them:

set mailcap_path=~/.mailcap
set certificate_file=~/.mutt/certificates
set mbox_type=Maildir
set mbox="~/.mutt"
set folder="~/.mutt"

We then need to add the directories for the individual account configs so that mutt is aware of them:

folder-hook 'account1' 'source ~/.mutt/account1/config'
folder-hook 'account2' 'source ~/.mutt/account2/config'
folder-hook 'account3' 'source ~/.mutt/account3/config'

If you want to always have mutt attempt to load one specific account when it is opened, you can use this, but I do not:

source ~/.mutt/account1/config

Now, if you have an IMAP folder that has a space in its name, you need this:

bind editor <space> noop

Here's the real magic. To switch accounts, you will simply hit a key sequence once mutt is opened. I use escape then a number:

macro index \e1 '<enter-command>source ~/.mutt/account1/config<enter><change-folder>!<enter><enter-command>source ~/.muttrc<enter>'
macro index \e2 '<enter-command>source ~/.mutt/account2/config<enter><change-folder>!<enter><enter-command>source ~/.muttrc<enter>'
macro index \e3 '<enter-command>source ~/.mutt/account3/config<enter><change-folder>!<enter><enter-command>source ~/.muttrc<enter>'

You may also wish to have a shortcut to fetch new mail:

bind index G imap-fetch-mail

I use threaded views, so new mail isn't actually always at the top of the pager so I have a shortcut for jumping to new messages:

macro index     .n      "<next-unread-mailbox><enter><next-new-then-unread><enter>" "Go to new mail"

That's it.

For each account, you can use something similar to this:

unmailboxes *
########################
# LOCAL FILES AND SUCH #
########################
set folder=~/.mutt/account1/mail
set signature=~/.mutt/account1/sig
set header_cache=~/.mutt/account1/headers
set message_cachedir=~/.mutt/account1/bodies
mailboxes =Inbox =Sent =Trash
########
# SMTP #
########
set smtp_url="smtps://username@smtp.mail.server:587/"
set smtp_pass="super secret password here"
set from="user@mail.server"
set realname="Socrates"
set smtp_authenticators = "gssapi:login"
########
# IMAP #
########
set imap_user="username@mail.server"
set imap_pass="super secret password here"
set folder="imaps://imap.mail.server/"
set postponed = "+Drafts"
set spoolfile="+INBOX"
set record = "+Sent"
###################
# VARIOUS OPTIONS #
###################
set imap_pipeline_depth=0
set imap_keepalive=240
set timeout=30
set mail_check=30
set sort=threads
set sort_aux=reverse-date-received
set move=no
set mark_old=no
set editor=vim
set markers=no
set include=yes
set forward_format="Fwd: %s"
set ssl_force_tls=yes
set ssl_starttls=yes
set copy=yes
set sig_on_top=yes 
auto_view text/html
set crypt_use_gpgme=no
##########
# COLORS #
##########
color normal     white        default
color attachment brightyellow default
color hdrdefault cyan         default
color indicator  brightred    default
color markers    brightred    default
color quoted     green        default
color signature  cyan         default
color tilde      blue         default
color tree       red          default
color quoted1    green        default
color index      yellow       default "~N"
color index      yellow       default "~U"
# URLS
color body brightblue  black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"
color body brightblue  black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"
mono  body bold              "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"
mono  body bold              "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"
# EMAIL ADDRESSES
color body brightblue  black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"
mono  body bold              "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"
# SMILIES AND SUCH
color body brightgreen black "<[Ee]?[Bb]?[Gg]>"     # <g>
color body brightgreen black "<[Bb][Gg]>"       # <bg>
color body brightgreen black " [;:]-*[)>(<|]"       # :-) etc...
# SUPER IMPORTANT PERSON SENT ME SOMETHING 
color index magenta default '~f someoneImportant@domain.tld'
# EOF

This should get you going. You will most certainly find more and more about mutt as you duckduckgo to find more configuration options and the like. Enjoy.

⇠ back

© MMIX - MMXX, absurd.wtf
Licentiam Absurdum