[neomutt-users] My multi-account setup

Pietro Cerutti gahr at gahr.ch
Tue Aug 25 11:14:24 CEST 2020


For those who might have missed it (or for newcomers).

On Jun 22 2020, 10:17 UTC, Pietro Cerutti <gahr at gahr.ch> wrote:
>Hi all,
>
>I recently shared my multi-account setup with a number of users who 
>asked for a solution on #neomutt. The overall reaction was positive, 
>so I thought I'd share it with you all.
>
>I am not claiming this is the best way to go about it. It's just how I 
>got to a point where switching between account isn't a pain for me.
>
>0. Background
>
>I use NeoMutt purely as a front-end to IMAP. All my emails are stored 
>remotely, on a number of IMAP accounts. I don't use maildirs or 
>notmuch.  No sync'ing. Just pure network access to IMAP. Sending email 
>is done through each account's SMTP server.
>
>1. Goals
>
>I want it to be easy to switch between accounts. I always only want to 
>see context related to one account at a time. I don't copy emails 
>between accounts. I want the switching to be explicit. I don't use 
>folder-hooks (for this purpose).
>
>2. Method
>
>I define a number of config files, one for each account.  They all 
>look pretty similar, if not for how different IMAP servers organize 
>well-known mailboxes such as Sent or Trash.  I define macros to source 
>these files in a smart way (see imap_post.cfg and the my_imap_done 
>variable below).  I have a main config file where I list all accounts 
>and bind macros to them.  This also allows me to set up general config 
>entries that are valid for all accounts.
>
>3. Authentication
>
>I store sensitive information such as my usernames and passwords in 
>my_ variables. These are set at startup and always valid. Different 
>accounts get different my_ variables.
>
>4. The files
>
>4.1 imap.cfg
>
>The entry point for my multi-account config is the main imap.cfg file:
>
>######################################################################
># ~/.config/neomutt/imap.cfg
>
># the default account to load when NeoMutt starts up
>source ./imap_gmail.cfg
>
># macros for switching between accounts
>macro index <F6> "<enter-command>unmailboxes *<enter><enter-command>source ~/.config/neomutt/imap_fastmail.cfg<enter><sync-mailbox>"
>macro index <F7> "<enter-command>unmailboxes *<enter><enter-command>source ~/.config/neomutt/imap_gmail.cfg<enter><sync-mailbox>"
>macro index <F8> "<enter-command>unmailboxes *<enter><enter-command>source ~/.config/neomutt/imap_hotmail.cfg<enter><sync-mailbox>"
>
># config valid for all accounts
>set imap_check_subscribed = yes
>set imap_authenticators = plain
>
># needed to skip reloading the default account on start up
>set my_imap_done = true
>######################################################################
>
>4.2 imap_fastmail.cfg
>
>FastMail.com account file. Works with an app-password.
>
>######################################################################
># ~/.config/neomutt/imap_fastmail.cfg
>
>set my_imap = imaps://$my_fastmail_user@imap.fastmail.com/
>
>set imap_pass = $my_fastmail_pass
>
>set folder    = "$my_imap"
>set spoolfile = +INBOX
>set postponed = +Drafts
>set record    = +Sent
>set trash     = +Trash
>set move      = no
>
>set smtp_authenticators = plain
>set smtp_url  = smtps://$my_fastmail_user@smtp.fastmail.com
>set smtp_pass = $my_fastmail_pass
>
>source ./imap_post.cfg
>######################################################################
>
>4.3 imap_gmail.cfg
>
>GMail.com account file. Works with an app-password.
>
>######################################################################
># ~/.config/neomutt/imap_gmail.cfg
>set my_imap = imaps://$my_gmail_user@imap.gmail.com/
>
>set imap_pass = $my_gmail_pass
>
>set folder    = "$my_imap"
>set spoolfile = +INBOX
>set postponed = +[Gmail]/Drafts
>set record    = "+[Gmail]/Sent Mail"
>set trash     = +[Gmail]/Trash
>set move      = no
>
>set smtp_authenticators = plain
>set smtp_url  = smtps://$my_gmail_user@smtp.gmail.com
>set smtp_pass = $my_gmail_pass
>
>source ./imap_post.cfg
>######################################################################
>
>4.4 imap_hotmail.cfg
>
>Hotmail.com account file.
>
>######################################################################
># ~/.config/neomutt/imap_hotmail.cfg
>
>set my_imap = imaps://$my_hotmail_user@imap-mail.outlook.com
>
>set imap_pass = $my_hotmail_pass
>
>set folder    = "$my_imap"
>set spoolfile = +INBOX
>set postponed = +Drafts
>set record    = +Sent
>set trash     = +Trash
>set move      = no
>
>set smtp_authenticators = plain
>set smtp_url  = smtps://$my_hotmail_user@smtp-mail.outlook.com
>set smtp_pass = $my_hotmail_pass
>
>source ./imap_post.cfg
>######################################################################
>
>4.5 imap_post.cfg
>
>Switches to $folder after loading an account file. It is guarded by 
>my_imap_done so I don't load the default account twice on start up.
>
>######################################################################
># ~/.config/neomutt/imap_post.cfg
>
>ifdef my_imap_done "push <change-folder>$my_imap<enter>"
>######################################################################
>
>That's the bulk of it.  Feel free to adopt / enhance / fix / comment. 
>I'll keep the most up-to-date version as a gist on github:
>https://gist.github.com/gahr/870e866fa9c6bf7e6818cca39b304a40
>
>Thanks,
>
>
>-- 
>Pietro Cerutti

-- 
Pietro Cerutti


More information about the neomutt-users mailing list