Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active March 16, 2024 12:52
Show Gist options
  • Save miguelmota/9456162 to your computer and use it in GitHub Desktop.
Save miguelmota/9456162 to your computer and use it in GitHub Desktop.
Multiple accounts with Mutt E-Mail Client (gmail example)

How to set up multiple accounts with Mutt E-mail Client

Thanks to this article by Christoph Berg

Instructions

Directories and files

~/
|── .mutt/
|   ├── account.com.gmail.foo
|   ├── account.com.gmail.bar
|   ├── com.gmail.foo/
|   └── com.gmail.bar/
└── .muttrc
~/.muttrc
# Folder hooks
folder-hook 'account.com.gmail.foo' 'source ~/.mutt/account.com.gmail.foo'
folder-hook 'account.com.gmail.bar' 'source ~/.mutt/account.com.gmail.bar'

# Default account
source ~/.mutt/account.com.gmail.foo         

# Macros for switching accounts
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/account.com.gmail.foo<enter><change-folder>!<enter>'
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/account.com.gmail.bar<enter><change-folder>!<enter>'

# Fetch mail shortcut
bind index G imap-fetch-mail
~/.mutt/account.com.gmail.foo
set imap_user = "foo@gmail.com"                       
set imap_pass = "<PASSWORD>"                                    
set smtp_url = "smtp://foo@smtp.gmail.com:587/"       
set smtp_pass = "<PASSWORD>"                                    
set from = "foo@gmail.com"                            
set realname = "Foo"                                  
set folder = "imaps://imap.gmail.com:993"                     
set spoolfile = "+INBOX"                                      
set postponed = "+[Gmail]/Drafts"                             
set header_cache = ~/.mutt/com.gmail.foo/cache/headers            
set message_cachedir = ~/.mutt/com.gmail.foo/cache/bodies         
set certificate_file = ~/.mutt/com.gmail.foo/certificates         
~/.mutt/account.com.gmail.bar
set imap_user = "bar@gmail.com"                       
set imap_pass = "<PASSWORD>"                                    
set smtp_url = "smtp://bar@smtp.gmail.com:587/"       
set smtp_pass = "<PASSWORD>"                                    
set from = "bar@gmail.com"                            
set realname = "Bar"                                  
set folder = "imaps://imap.gmail.com:993"                     
set spoolfile = "+INBOX"                                      
set postponed = "+[Gmail]/Drafts"                             
set header_cache = ~/.mutt/com.gmail.bar/cache/headers            
set message_cachedir = ~/.mutt/com.gmail.bar/cache/bodies         
set certificate_file = ~/.mutt/com.gmail.bar/certificates         
@dmzely
Copy link

dmzely commented Oct 21, 2018

Thanks!!!

@doa379
Copy link

doa379 commented Feb 13, 2019

oh mutt still sucks

@mcepl
Copy link

mcepl commented May 2, 2019

How can I copy/move messages between two IMAP accounts? Is there a way how to make some kind of aliases, so that I don't have to copy to imaps://matej#foo@imap.somewhere.company.com/INBOX/somefolder all the time?

@minusf
Copy link

minusf commented May 5, 2019

the problem with these setups is that if any of the imap accounts are not reachable mutt will go into an infinite loop and it's not possible to even switch to any of the other ones. mutt just wasn't built for this.

@amiralshamiah
Copy link

how can i convert a mutt-e-mail into postgresql database

@vladimirtamayo
Copy link

In neomutt I had to change imap folder parameter set folder = "imaps://$imap_user@imap.gmail.com:993"

@chekmanh
Copy link

Thank you very much

@hasufell
Copy link

Doesn't work in mutt, only in neomutt. Mutt hangs forever on sorting emails when switching accounts.

@talau
Copy link

talau commented May 14, 2021

Thanks for the article. Here you can find another way to use multiple mutt accounts.

@carlcidromero
Copy link

@IanDarwin
Copy link

how can i convert a mutt-e-mail into postgresql database

Look into archiveopteryx, a back-end for storing mail in postgresql.

@jbjoeB
Copy link

jbjoeB commented Nov 10, 2022

To refresh the sidebar, you have to put this in all of your account files and change the mailboxes command to include all the mailboxes you want to show up. But I think there is a bug in the unmailboxes * command which I'm not sure has been fixed yet.

unmailboxes * mailboxes "+Inbox" "+[Gmail]/All Mail"

This resolved my issue after a couple of days looking for an answer. I even asked on irc and they were stumped.

it's 12:27pm PST 10/10/22

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment