domainaware / parsedmarc

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

Erro (folder INBOX not found) in MsGraph setup #388

Closed botkillern closed 1 year ago

botkillern commented 1 year ago

Hello, Folks!

I'm facing some error when trying to deploy parsedmarc in my environment.

The first is...When I tried to use by IMAP config, I can't authenticate because Office 365 doesn't support legacy IMAP Auth. Support to Legacy is available just in SMTP protocol. S o I decide to setup a MSGraph schema, but now I'm having this trouble.

Everytime I run parsedmarc I got this error:

   ERROR:cli.py:985:Mailbox Error
Traceback (most recent call last):
  File "/opt/pypy/lib/pypy3.9/site-packages/parsedmarc/cli.py", line 968, in _main
    reports = get_dmarc_reports_from_mailbox(
  File "/opt/pypy/lib/pypy3.9/site-packages/parsedmarc/__init__.py", line 1085, in get_dmarc_reports_from_mailbox
    messages = connection.fetch_messages(reports_folder, batch_size=batch_size)
  File "/opt/pypy/lib/pypy3.9/site-packages/parsedmarc/mail/graph.py", line 145, in fetch_messages
    folder_id = self._find_folder_id_from_folder_path(folder_name)
  File "/opt/pypy/lib/pypy3.9/functools.py", line 588, in wrapper
    result = user_function(*args, **kwds)
  File "/opt/pypy/lib/pypy3.9/site-packages/parsedmarc/mail/graph.py", line 217, in _find_folder_id_from_folder_path
    return self._find_folder_id_with_parent(folder_name, None)
  File "/opt/pypy/lib/pypy3.9/site-packages/parsedmarc/mail/graph.py", line 234, in _find_folder_id_with_parent
    raise RuntimeError(f"folder {folder_name} not found")
RuntimeError: folder INBOX not found

RuntimeError: folder INBOX not found

Before I came here, I tried to have sure about permissions and to know if "INBOX" folder exist. So I use a Python script to reach the same endpoint in graph.py and I got positive answer. I can see "Inbox" folder in the list.

Result of my python request:

{'id': 'FODLER_ID', 'displayName': 'Inbox', childFolderCount': 0, 'unreadItemCount': 34, 'totalItemCount': 39, 'sizeInBytes': 7763627, 'isHidden': False}
Response Code:200
Request URL:  https://graph.microsoft.com/v1.0//users/redacted_info/mailFolders

Someone can help me? Please

botkillern commented 1 year ago

Hi, Folks!

I found a solution to my issue!

I set these parameters on parsedmarc.ini file to get the expected result and worked like a charm!

[mailbox]
reports_folder = Inbox
watch = True

I think MSGraph handle with case sensitive type, so parsedmarc query for INBOX that doesn't exist so I used Inbox and worked.