Unsetting mutt's configuration variables imap_user
, imap_pass
(and perhaps preconnect
, imap_authenticators
as well) via an account-hook . "unset ... "
call, seems to be common practice, if not a necessity, for handling multiple imap accounts (see Managing multiple IMAP/POP accounts (OPTIONAL), Mutt imap multiple account, mutt: gmail IMAP unresponsive, an account-hook related configuration file in funtoo.org).
Currently I handle only one account via IMAP. Plans for multiple account handling lead me to follow the instructions found in the last of the above mentioned links (someone's example of mutt configuration). Therefore, in a similar way, I used the following:
account-hook . 'unset imap_user; unset imap_pass; unset tunnel'
account-hook 'imaps://mail.domain.net:993/INBOX/' "set imap_user=UserName@domain.net"
account-hook 'imaps://mail.domain.net:993/INBOX/' "set imap_pass=${my_password}"
This is stored in a separate file (named account_hooks
) and sourced from inside muttrc
. For reasons I don't understand, mutt keeps asking for the username and the password. However, if the variables imap_user
and imap_pass
are set directly in muttrc
, e.g.
set my_password="`gpg --decrypt ~/.mutt/password.gpg`"
set imap_authenticators='login'
set imap_login = 'UserName@domain.net'
set imap_user = 'UserName@domain.net'
set imap_pass ="${my_password}"
everything works fine. The account_hooks
file is the first one sourced and no other account-hook . "unset ..."
call(s) exist(s) anywhere else.
Update, The folder-hooks
file is (and was, I think) as follows:
#--------------------------------------------------------------------------
# Folders and hooks
#--------------------------------------------------------------------------
# folder-hook 'imaps://UserName%domain.net@mail.domain.net:993/'
set folder = "~/.maildir" # IMAP: local, using offlineimap -- folder="imaps://mail.domain.net:993/INBOX/"
source ~/.mutt/mailboxes # source automatically generated mailboxes
set spoolfile = "+INBOX" # spoolfile='imaps://mail.domain.net:993/'
set postponed = "+INBOX/Drafts"
# Sending -----------------------------------------------------------------
set smtp_url="smtp://UserName@domain.net@mail.domain.net:587/"
set smtp_pass=${my_password}
set record = "+INBOX/Sent"
set copy=yes
# Index format ----------------------------------------------------------------
folder-hook *[sS]ent* 'set sort=threads'
folder-hook *[sS]ent* 'set sort_browser=reverse-date'
folder-hook *[sS]ent* 'set sort_aux=reverse-last-date-received'
folder-hook *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30t (%-4.4c) %s"'
folder-hook ! *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"':
Why does, the separate file account_hooks, not feed properly the variables of interest in this case (i.e. imap_user and imap_pass)?
folder-hook
lines you have in your.muttrc
. Then I can draw some conclusions and offer a complete solution.folder-hook
settings I used at the time, I guess I have'm as a backup.DEBUG was not defined during compilation. Ignored.
. Once I'll find some time, I'll recompile and post back.