This is an OS X-centric configuration.
The idea here is to use environment variables, loaded via aliases to mutt, to control which account you're loading. Years ago I had all of my accounts configured to be accessible from a single mutt configuration, but I find the simplicity and symmetry of this configuration to work better for me.
Once your configuration is complete, you run mutt via the aliases
defined in mutt.bash
below.
The bash configuration in the Hermes project is the one I now use, but I'll just show you the relevant bits for mutt here.
function source_modules {
echo -en "Sourcing bash modules in $HOME/.bashrc.d/"
for f in $HOME/.bashrc.d/*.bash; do
load_and_handle_errors $f
done
echo -e ""
unset f
}
source_modules
export MAILCONF="$HOME/.mutt"
alias mutt-allolex="MUTT_INSTANCE=allolex mutt"
# make one alias for each account, e.g.
# alias mutt-work="MUTT_INSTANCE=work mutt"
I don't use a ~/.muttrc
.
Mutt can use environment variables in its config files.
# Aliases (I like to keep mine separate)
set alias_file = $MAILCONF/$MUTT_INSTANCE/aliases
source $MAILCONF/$MUTT_INSTANCE/aliases
# Caches
set header_cache=~/.mutt/$MUTT_INSTANCE/cache/headers
set message_cachedir=~/.mutt/$MUTT_INSTANCE/cache/bodies
set certificate_file=~/.mutt/$MUTT_INSTANCE/certificates
set spoolfile = "+INBOX"
# Source the correct instance muttrc last
source $MAILCONF/$MUTT_INSTANCE/muttrc
cache/
aliases
certificates
muttrc
This is the configuration specific to your mail account. The password is stored in your Keychain and loaded into config when mutt starts.
set imap_user = "[email protected]"
set imap_pass = `keychain_password example_gmail_service`
set smtp_url = "smtp://[email protected]@smtp.gmail.com:587/"
set smtp_pass = `keychain_password example_gmail_service`
set from = "[email protected]"
set realname = "Your Name"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set imap_check_subscribed
set hostname = example.com
set postponed = "+[GMail]/Drafts"
set record = "+[GMail]/Sent Mail"