mailnag
mailnag copied to clipboard
Error: No mailbox selected
I'm using mail-client/mailnag-9999 (git version) on a Gentoo Linux system. It was built on Sept 1st. I'm also using the corresponding GNOME extension.
Today I noticed mailnag stopped checking messages from my e-mail accounts. In journalctl
I discovered multiple error similar to the following one:
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: ERROR (2016-09-13 18:53:10): Caught an exception.
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: Traceback (most recent call last):
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mailnagdaemon.py", line 183,
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: self._mailchecker.check(self._accounts)
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mailchecker.py", line 58, in
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: all_mails = self._mailsyncer.sync(accounts)
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mails.py", line 279, in sync
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: rcv_lst = MailCollector(self._cfg, accounts).collect_mail(sort = False)
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mails.py", line 116, in coll
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: conn.close()
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: File "/usr/lib64/python2.7/site-packages/Mailnag/common/imaplib2.py", line 669, in c
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: raise self.error('No mailbox selected.')
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: error: No mailbox selected.
Sep 13 18:53:11 desktop mailnag-config.desktop[3672]: INFO (2016-09-13 18:53:10): Checking 1 email account(s).
Sep 13 18:53:11 desktop mailnag[3702]: ERROR (2016-09-13 18:53:10): Caught an exception.
Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mailnagdaemon.py", line 183, in _start
self._mailchecker.check(self._accounts)
File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mailchecker.py", line 58, in check
all_mails = self._mailsyncer.sync(accounts)
File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mails.py", line 279, in sync
rcv_lst = MailCollector(self._cfg, accounts).collect_mail(sort = False)
File "/usr/lib64/python2.7/site-packages/Mailnag/daemon/mails.py", line 116, in collect_mail
conn.close()
File "/usr/lib64/python2.7/site-packages/Mailnag/common/imaplib2.py", line 669, in close
raise self.error('No mailbox selected.')
error: No mailbox selected.
Sep 13 18:53:11 desktop mailnag[3702]: INFO (2016-09-13 18:53:10): Checking 1 email account(s).
I solved the problem by editing the folder
variable for my mail e-mail account in ~/.config/mailnag/mailnag.cfg
. I had to remove one folder that I previously removed via the webmail interface but that was still there in the configuration file. After restarting mailnag e-mail notifications resumed.
I think mailnag should not silently fail in this case, but either directly warn the user with some kind of error message or (better) continue functioning as normal despite the missing folder.
Some analysis:
In mails.py MailColector.collect_mail loops all defined folders. It selects a folder, and if the folder does not exist connection does not go to select state and next search fails. This is logged as warning. Then it loops to next folder and so on.
Now if the non-existing folder is last in the folder list, connection stays in not-selected state (auth-state, I think), close after the loop fails and causes that exception.
This exception is raised if accounts idle parameter is false (which in the case if account has multiple connections). If idle parameter is true (which is the case when only one folder is defined), then other exception is raised, because next idle command fails.
The folder that I removed from the configuration file was the last one in the list.