You are not logged in.

#1 2018-09-13 16:25:24

vollassitoni69
Member
Registered: 2018-09-13
Posts: 6

[SOLVED] Mutt/Neomutt - cannot switch between email accounts

Hello, I've been trying to set up mutt/neomutt as my email client using the ArchWiki's mutt article the past few days and have come across an issue. I have two email accounts as specified in the configuration files below. Naturally when I startup mutt/neomutt it asks me for the password of the account that was last sourced in muttrc (accB). Logging in to the account and retrieving email works fine. When I switch to account A (with 'gA') it prompts me for "Password for userA@hostA.com@imap.hostA.com". I enter the password and it does a bunch of stuff for half a second (which happens so quickly I can't read the status bar) and then prompts me for "Password for userA@hostA.com@imap.hostB.com" (note the 'B' at the end), after which login fails. When I change the order of accounts in ~/.mutt/muttrc, login works fine for account A but switching to account B fails in the same manner as described above (prompts me first for passwd for userB@hostB.com, does some stuff for half a second, then prompts me for passwd for userB@hostA.com). Does anybody have any idea what's going on here? I've been trying to solve this for a while and have gotten nowhere, so I will be eternally grateful for any help!

 # ~/.mutt/muttrc
set imap_check_subscribed 
set header_cache       = "~/.cache/mutt/headers" 
set message_cachedir   = "~/.cache/mutt/messages" 
unset imap_passive 

## ACCOUNT A
source "~/.mutt/accA"
folder-hook $folder 'source ~/.mutt/accA'

## ACCOUNT B
source "~/.mutt/accB"
folder-hook $folder 'source ~/.mutt/accA'

bind index,pager g noop

# keybinding for opening accA folder
macro index,pager gA '<sync-mailbox><enter-command>source ~/.mutt/accA<enter><change-folder>!<enter>'
# keybinding for opening accB folder
macro index,pager gB '<sync-mailbox><enter-command>source ~/.mutt/accB<enter><change-folder>!<enter>'
 # ~/.mutt/accA
## IMAP SETTINGS (for receiving mail)
set imap_user          = 'userA@hostA.com'
set folder             = "imap://imap.hostA.com/"
set spoolfile          = +INBOX
## CONNECTION OPTIONS
set ssl_starttls       = yes
unset ssl_force_tls
 # ~/.mutt/accB
## IMAP SETTINGS (for receiving mail)
set imap_user          = userB
set folder             = "imap://imap.hostB.com/"
set spoolfile          = +INBOX
## CONNECTION OPTIONS
set ssl_starttls       = yes
set ssl_force_tls      = yes

Last edited by vollassitoni69 (2018-09-13 19:56:42)

Offline

#2 2018-09-13 16:40:32

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Mutt/Neomutt - cannot switch between email accounts

account-hook $folder "set imap_user=userA"
account-hook $folder "set imap_user=userB"

I've also hardcoded the foldernames in muttrc/folder-hook calls (iirc $folder didn't update or just used the last include, no idea whether that's still true)

Offline

#3 2018-09-13 17:32:16

vollassitoni69
Member
Registered: 2018-09-13
Posts: 6

Re: [SOLVED] Mutt/Neomutt - cannot switch between email accounts

seth wrote:

account-hook $folder "set imap_user=userA"
account-hook $folder "set imap_user=userB"

That solved it! Thank you so much! Do you know why this works? Shouldn't the imap_user variable be set when the other account file is sourced? Should I file a bug report for this (or update the ArchWiki page)?

Offline

#4 2018-09-14 06:38:50

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Mutt/Neomutt - cannot switch between email accounts

I did what every smart arch user does and consulted https://wiki.archlinux.org/index.php/Mu … e_accounts ;-)
The point here is (as I understand) that several actions are either untied from the current folder or (in this case) take place before the folder is actually changed (eg. logging in), so the folder hooks simply did not hit at this point.

Offline

#5 2018-09-18 15:29:03

vollassitoni69
Member
Registered: 2018-09-13
Posts: 6

Re: [SOLVED] Mutt/Neomutt - cannot switch between email accounts

Believe it or not, I did read the ArchWiki page before posting here and I made my configuration according to the example configuration provided there. I know what account hooks are, just never thought to include one in my config (since the wiki's configuration did not contain one). That's why I asked whether or not to change the example config provided in the ArchWiki page so that other intellectually less capable individuals such as myself don't run into the same issue. Thanks for your explanation!

Offline

#6 2018-09-18 18:49:59

seth
Member
Registered: 2012-09-03
Posts: 50,924

Re: [SOLVED] Mutt/Neomutt - cannot switch between email accounts

In case this came off wrongly: i didn't mean that as insult.
It is really the only way why I "knew" this would work (since it is in the wiki, along the note "## Hook -- IMPORTANT!")
I actually thought about it first time after your question.

Offline

#7 2018-09-23 15:45:39

vollassitoni69
Member
Registered: 2018-09-13
Posts: 6

Re: [SOLVED] Mutt/Neomutt - cannot switch between email accounts

Don't worry, I didn't interpret it as an insult!
Oh snap I just noticed the "##Hook -- IMPORTANT!" comment in mutt/work - wasn't prepared to see hooks in the account config file, only looked in the muttrc file since that's where the folder hook was. Sorry for wasting your time! I guess I just missed it.

Offline

Board footer

Powered by FluxBB