domainaware / parsedmarc

A Python package and CLI for parsing aggregate and forensic DMARC reports
https://domainaware.github.io/parsedmarc/
Apache License 2.0
961 stars 209 forks source link

Error connecting to IMAP using DavMail #505

Open PerryCodes opened 3 months ago

PerryCodes commented 3 months ago

Getting this when connecting to DavMail regardless of the 'reports_folder' value:

    INFO:cli.py:1031:Starting parsedmarc
0it [00:00, ?it/s]   ERROR:cli.py:1257:IMAP Error
Traceback (most recent call last):
  File "C:\Program Files\Python39\lib\imaplib.py", line 1047, in _command_complete
    typ, data = self._get_tagged_response(tag, expect_bye=logout)
  File "C:\Program Files\Python39\lib\imaplib.py", line 1173, in _get_tagged_response
    self._get_response()
  File "C:\Program Files\Python39\lib\imaplib.py", line 1104, in _get_response
    raise self.abort("unexpected response: %r" % resp)
imaplib.IMAP4.abort: unexpected response: b'*  22279 EXISTS'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\jperry\AppData\Roaming\Python\Python39\site-packages\mailsuite\imap.py", line 185, in __init__
    self.select_folder(initial_folder)
  File "C:\Users\jperry\AppData\Roaming\Python\Python39\site-packages\imapclient\imapclient.py", line 819, in select_folder
    self._command_and_check("select", self._normalise_folder(folder), readonly)
  File "C:\Users\jperry\AppData\Roaming\Python\Python39\site-packages\imapclient\imapclient.py", line 1752, in _command_and_check
    typ, data = meth(*args)
  File "C:\Program Files\Python39\lib\imaplib.py", line 756, in select
    typ, dat = self._simple_command(name, mailbox)
  File "C:\Program Files\Python39\lib\imaplib.py", line 1230, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "C:\Program Files\Python39\lib\imaplib.py", line 1049, in _command_complete
    raise self.abort('command: %s => %s' % (name, val))
imaplib.IMAP4.abort: command: SELECT => unexpected response: b'*  22279 EXISTS'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\jperry\AppData\Roaming\Python\Python39\site-packages\parsedmarc\cli.py", line 1245, in _main
    mailbox_connection = IMAPConnection(
  File "C:\Users\jperry\AppData\Roaming\Python\Python39\site-packages\parsedmarc\mail\imap.py", line 24, in __init__
    self._client = IMAPClient(host, user, password, port=port,
  File "C:\Users\jperry\AppData\Roaming\Python\Python39\site-packages\mailsuite\imap.py", line 191, in __init__
    raise imapclient.exceptions.IMAPClientError(error)
imaplib.IMAP4.error: command: SELECT => unexpected response: b'*  22279 EXISTS

Any suggestions?

PerryCodes commented 3 months ago

Here's a screenshot of the DavMail log a little bit earlier in the day when the error would have read 22275 EXISTS.

image

PerryCodes commented 2 months ago

@seanthegeek - Any ideas? I can connect to DavMail with Thunderbird with zero problems. Mail shows fine. So this indicates to me that something is wrong with IMAP in the Python libs, the way parsedmarc is using those libs, or the way either is parsing the response(s) from DavMail.

PerryCodes commented 2 months ago

The powers that be allowed IMAP to be enabled on Exchange for a test and it works successfully when connected directly to Exchange via IMAP. I'm now convinced that parsing of DavMail output isn't being performed correctly. Thought I was going to make it out of this life without learning Python, but that's looking less likely ;)