Thanks for this code which is helpfull
It took me 2 hours to figure out my IMAP directory was misspelled in the config file.
Indeed, when the IMAP directory is not ok, the following exception occurs:
[INFO]: Connected to IMAP server.
Traceback (most recent call last):
File "./imap2thehive.py", line 548, in <module>
main()
File "./imap2thehive.py", line 544, in main
readMail(mailConnect())
File "./imap2thehive.py", line 402, in readMail
typ, dat = mbox.search(config['imapFolder'], '(UNSEEN)')
File "/usr/lib/python3.7/imaplib.py", line 721, in search
typ, dat = self._simple_command(name, 'CHARSET', charset, *criteria)
File "/usr/lib/python3.7/imaplib.py", line 1196, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/usr/lib/python3.7/imaplib.py", line 944, in _command
', '.join(Commands[name])))
imaplib.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED
I'm using O365
It occurs here:
https://github.com/xme/dockers/blob/master/imap2thehive/imap2thehive.py#L402
I manage to understand my mistake by adding the code:
for i in mbox.list()[1]:
l = i.decode().split(' "/" ')
print(l[0] + " = " + l[1])
Do dump the folder list.
I'm not a python guy so I cannot push a PR, but my suggestion would be just before selecting the folder, check in mbox.list() if there is an item matching the name (if there is an exception or every time)
And to add a comment in the config file that if you aim at a subfolder name have to prefix it like INBOX\Folder and that the INBOX folder is usually independent of the language.
Thanks for this code which is helpfull
It took me 2 hours to figure out my IMAP directory was misspelled in the config file.
Indeed, when the IMAP directory is not ok, the following exception occurs:
I'm using O365
It occurs here:
https://github.com/xme/dockers/blob/master/imap2thehive/imap2thehive.py#L402
I manage to understand my mistake by adding the code:
Do dump the folder list.
I'm not a python guy so I cannot push a PR, but my suggestion would be just before selecting the folder, check in mbox.list() if there is an item matching the name (if there is an exception or every time)
And to add a comment in the config file that if you aim at a subfolder name have to prefix it like INBOX\Folder and that the INBOX folder is usually independent of the language.