How to use mutt with multiple email accounts

I encountered some issues setting up multiple email accounts with mutt, so I decided to provide as much info as possible for other people who may encounter issues doing the same.

One Google Apps hosted and another (hosted with my company) email accounts were set up in this tutorial, make sure you change personal details like username, password, email account.

1) Install MUTT email client and the needed dependencies:

For RPM based distributions use:

yum install cyrus-sasl-plain mutt

For DEB based distributions use:

apt-get install libsasl2 mutt

2) Create a new file called .muttrc  in your home directory (do not ignore the leading dot “.”)

macro index <F5> 'source ~/.mutt/appsdomain.tld!' 
macro index <F6> 'source ~/.mutt/companydomain.tld!'
account-hook appsdomain.tld 'set [email protected] imap_pass=appsaccountpassword'
account-hook companydomain.tld 'set [email protected] imap_pass=companyaccountpassword'
set move = no  #Prevents mutt from asking to move read messages to INBOX
set imap_keepalive = 900
ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc #Sorting emails by the given criteria (from left to right)
ignore *
unignore from: date subject to cc
unignore x-mailing-list: posted-to:
unignore x-mailer: #Nice looks
set markers=no # removes the "+" sign from the beginning of wrapped lines
set pager_index_lines= 5
set sort = 'threads'
set sort_aux = 'last-date-received' 
#Set your editor
set editor='vim + -c "set textwidth=80" -c "set wrap" -c "set nocp" -c "?^$"'
# .mutt/muttrc
folder-hook 'appsdomain.tld' 'source ~/.mutt/appsdomain.tld'
folder-hook 'companydomain.tld' 'source ~/.mutt/companydomain.tld'
# Choose which account should be loaded on startup, uncomment only one of these:
#source ~/.mutt/appsdomain.tld 
#source ~/.mutt/companydomain.tld

3) Create the .mutt directory for storing special/per account configuration files

mkdir -p /home/yourusername/.mutt/ 

4) Create the configuration file for your first account (appsdomain.tld for me):

color status cyan default
set from = "[email protected]"
set realname = "Firstname Lastname"
set imap_user = "[email protected]"
set imap_pass = "appsaccountpassword"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed ="+[Gmail]/Drafts"
set certificate_file =~/.mutt/certificates

5) Create the configuration file for your second account (companydomain.tld for me):

color status green default
set from = "[email protected]"
set hostname = "companydomain.tld"
set folder = "imaps://companydomain.tld/"
set postponed = "=Drafts"
set spoolfile = "imaps://companydomain.tld/INBOX"
set signature = "~/.mutt/companydomain.tld.signature"

6) Set a signature for your accounts (optional)

cat << 'EOF' > ~/.mutt/companydomain.tld.signature
Kind regards,
FirstName LastName
Your Company
EOF

7) Open mutt by simply typing mutt in your console:

mutt

8) Press F5 to switch to your first account (you should notice notice the “blueish” cyan colour):

mutt_first_account
Mutt First Account

9) Press F6 to switch to your second account (notice the green colour):

Mutt Second Account
Mutt Second Account

10) Job done – and this is how you set up mutt with multiple email accounts!

13 thoughts on “How to use mutt with multiple email accounts”

  1. Please I’m getting an error on lines:
    macro index ‘source ~/.mutt/first_accountl’
    macro index ‘source ~/.mutt/second_accout’

    Thought mutt starts after typing any key. Please can you give me a clue what I’ve done wrong? Thanks

    Reply
  2. Same errors line 1 and 2…

    macro index ‘source ~/.mutt/joglo35!’
    macro index ‘source ~/.mutt/photo!’

    Thx for your help….regards

    Reply
  3. I’m getting a message when trying to switch accounts: Key is not bound
    How do you bound F5 and F6 to the different accounts?
    Thanks

    Reply
    • I’m really sorry I now just realised that somehow WordPress removed the < F5 > and < F6 > from these lines:

      macro index <F5> 'source ~/.mutt/appsdomain.tld!'
      macro index <F6> 'source ~/.mutt/companydomain.tld!'
      

      I updated the post, everything should be OK now if you update your config.

      Reply
  4. I’m getting an error on source line where only one line is to be uncommented. The acount definitely exists along with an accompanying directory under .mutt yet I’m being told it doesn’t exist.
    Also, is it podcasts or rss articles in the main feed on this page? That way I don’t try downloading rss content with vlc.

    Reply
  5. I love this — I have one problem. My inboxes are bound to f2-f5 and if I have an email open in the pager as I switch inbox it tries to forward the open message (brings up text editor and takes several keypresses to undo). How do I stop this?

    Reply
    • Hi Nick,

      Please post your config in code tags (make sure you remove any usernames/passwords!), maybe there’s something you missed/added extra, this does not happen to me.

      Reply
  6. Hi, when I try to source another account the save command is invoked instead and I get
    Save to mailbox: ource~/.mutt/[my other mail account]

    I have tried with both single and double quotes.

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.