Mutt imap multiple account

accountscommand lineimapmutt

My first question on this site, I come quickly.

I'm a fan of command line tools and text-based application. I use tmux with a minimalist tiling wm is qtile, I can not change the environment. I'm a developer, I mainly use Python and Perl.

My first question is about mutt a great client. I use the sidebar to be able to display mailboxes. I used imap with google accounts, Here is my configuration:

account-hook . 'unset preconnect imap_user imap_authenticators'

#First account
account-hook 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/' \
   ' set imap_user = "hobbestigrou@domain.com" \
     imap_pass = "password" '

folder-hook 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/INBOX' \
    ' set imap_user = "hobbestigrou@domain.com" \
      imap_pass = "1password" \
      smtp_url = "smtp://hobbestigrou@domain.com@smtp.gmail.com:587/" \
      smtp_pass = "password" \
      from = "hobbestigrou@domain.com" \
      realname = "Natal Ngétal" \
      folder = "imaps://hobbestigrou@domain.com@imap.gmail.com:993" \
      spoolfile = "+INBOX" \
      postponed="+[Gmail]/Drafts" \
      mail_check=60 \
      imap_keepalive=300 '

#Second account
account-hook 'imaps://hobbestigrou@domain2.com@imap.gmail.com:993/' \
    ' set imap_user = "hobbestigrou@domain2.com" \
      imap_pass = "password" '

folder-hook 'imaps://hobbestigrou@domain2.com@imap.gmail.com:993/INBOX' \
    ' set imap_user = "hobbestigrou@domain2.com" \
      imap_pass = "password" \
      smtp_url = "smtp://hobbestigrou@domain2.com@smtp.gmail.com:587/" \
      smtp_pass = "password" \
      from = "hobbestigrou@domain2.com" \
      realname = "Natal Ngétal" \
      folder = "imaps://hobbestigrou@domain2.com@imap.gmail.com:993" \
      spoolfile = "+INBOX" \
      postponed="+[Gmail]/Drafts" \
      mail_check=60 \
      imap_keepalive=300 '

mailboxes + 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/INBOX' \
          + 'imaps://hobbestigrou@dmain2.com@imap.gmail.com:993/INBOX' \
          + 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/[Gmail]/Messages envoyés' \
          + 'imaps://hobbestigrou@domain2.com@imap.gmail.com:993/[Gmail]/Messages envoyés' \
          + 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/[Gmail]/Spam' \
          + 'imaps://hobbestigrou@domain2.com@imap.gmail.com:993/[Gmail]/Spam' \
          + 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/Divers' \
          + 'imaps://hobbestigrou@domain2.com@imap.gmail.com:993/Divers' \
          + 'imaps://hobbestigrou@domain.com@imap.gmail.com:993/[Gmail]/Tous les messages' \
          + 'imaps://hobbestigrou@domain2.com@imap.gmail.com:993/[Gmail]/Tous les messages'

# Where to put the stuff
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"


set mail_check = 30
set move = no
set imap_keepalive = 900
set editor = "vim"

set date_format = "%D %R"
set index_format = "[%Z]  %D  %-20.20F  %s"
set sort = threads                         # like gmail
set sort_aux = reverse-last-date-received  # like gmail
set uncollapse_jump                        # don't collapse on an unread message
set sort_re                                # thread based on regex
set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"

bind index gg       first-entry
bind index G        last-entry

bind index R        group-reply
bind index <tab>    sync-mailbox
bind index <space>  collapse-thread

# Ctrl-R to mark all as read
macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mar

# Saner copy/move dialogs
macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"

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

set pager_index_lines = 10 # number of index lines to show
set pager_context = 3      # number of context lines to show
set pager_stop             # don't go to next message automatically
set menu_scroll            # scroll in menus
set tilde                  # show tildes like in vim
unset markers              # no ugly plus signs

bind pager k  previous-line
bind pager j  next-line
bind pager gg top
bind pager G  bottom

bind pager R  group-reply

set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
auto_view text/html                                      # view html automatically
alternative_order text/plain text/enriched text/html

set sidebar_delim   = '│'
set sidebar_visible = yes
set sidebar_width   = 24

set status_chars  = " *%A"
set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postpone

set beep_new             # bell on new mails
unset mark_old           # read/new is good enough for me

color normal    white black
color attachment brightyellow black
color hdrdefault cyan black
color indicator black cyan
color markers    brightred black
color quoted    green black
color signature cyan black
color status    brightgreen blue
color tilde    blue black
color tree    red black

color index    red black ~D
color index    magenta black ~T


set signature="~/.signature"

So it works well, I can see both my inbox and when there are new posts in it. But when I open mutt it first opened a local box, I do not understand why, and to see the new posts in other inbox, I have to move first in each of they. Maybe it's normal, but how by asking mutt to open domain.com for example first and not a local one that does not exist.

Best Answer

It's a little hard to see what you are trying to do, but are you by any chance looking for the $spoolfile variable/configuration setting in a global context?

I'm not sure how it interacts with Mutt's IMAP support, but it allows you to set the folder which will be opened by default when Mutt is started.

It looks like you set it in the account folder-hooks, but you'd need to set it outside of those in order for it to apply before the folder-hook folder is entered.

Try adding the following to the end of your ~/.muttrc, and see if it helps:

set spoolfile="imaps://hobbestigrou@domain.com@imap.gmail.com:993/INBOX"
Related Question