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

imaplib.IMAP4.error: LOGIN failed #506

Open Nenigon opened 3 months ago

Nenigon commented 3 months ago

The parsedmarc.service won't inicializate

status parsedmarc:

parsedmarc.service - parsedmarc mailbox watcher Loaded: loaded (/etc/systemd/system/parsedmarc.service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Thu 2024-04-04 17:42:07 -03; 4min 42s ago Docs: https://domainaware.github.io/parsedmarc/ Process: 2244 ExecStart=/usr/local/bin/parsedmarc -c /etc/parsedmarc.ini (code=exited, status=1/FAILURE) Main PID: 2244 (code=exited, status=1/FAILURE)

Error when i check executing 'sudo journalctl -eu parsedmarc':

Apr 04 17:42:06 xxx parsedmarc[2244]: WARNING:cli.py:592:Starting in 8.0.0, the watch option has been moved from the imap configuration section to the mailbox configuration section. Apr 04 17:42:06 xxx parsedmarc[2244]: WARNING:cli.py:639:Use of the watch option in the imap configuration section has been deprecated. Use this option in the mailbox configuration section in> Apr 04 17:42:07 xxx parsedmarc[2244]: /usr/local/lib/python3.8/dist-packages/elasticsearch/connection/base.py:208: ElasticsearchWarning: Elasticsearch built-in security features are not enable> Apr 04 17:42:07 xxx parsedmarc[2244]: warnings.warn(message, category=ElasticsearchWarning) Apr 04 17:42:07 xxx parsedmarc[2244]: ERROR:cli.py:1257:IMAP Error Apr 04 17:42:07 xxx parsedmarc[2244]: Traceback (most recent call last): Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/imapclient/imapclient.py", line 395, in login Apr 04 17:42:07 xxx parsedmarc[2244]: rv = self._command_and_check( Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/imapclient/imapclient.py", line 1752, in _command_and_check Apr 04 17:42:07 xxx parsedmarc[2244]: typ, data = meth(*args) Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/lib/python3.8/imaplib.py", line 603, in login Apr 04 17:42:07 xxx parsedmarc[2244]: raise self.error(dat[-1]) Apr 04 17:42:07 xxx parsedmarc[2244]: imaplib.IMAP4.error: b'LOGIN failed.' Apr 04 17:42:07 xxx parsedmarc[2244]: During handling of the above exception, another exception occurred: Apr 04 17:42:07 xxx parsedmarc[2244]: Traceback (most recent call last): Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/mailsuite/imap.py", line 162, in init Apr 04 17:42:07 xxx parsedmarc[2244]: self.login(username, password) Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/imapclient/imapclient.py", line 402, in login Apr 04 17:42:07 xxx parsedmarc[2244]: raise exceptions.LoginError(str(e)) Apr 04 17:42:07 xxx parsedmarc[2244]: imapclient.exceptions.LoginError: b'LOGIN failed.' Apr 04 17:42:07 xxx parsedmarc[2244]: During handling of the above exception, another exception occurred: Apr 04 17:42:07 xxx parsedmarc[2244]: Traceback (most recent call last): Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/parsedmarc/cli.py", line 1245, in _main Apr 04 17:42:07 xxx parsedmarc[2244]: mailbox_connection = IMAPConnection( Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/parsedmarc/mail/imap.py", line 24, in init Apr 04 17:42:07 xxx parsedmarc[2244]: self._client = IMAPClient(host, user, password, port=port, Apr 04 17:42:07 xxx parsedmarc[2244]: File "/usr/local/lib/python3.8/dist-packages/mailsuite/imap.py", line 191, in init Apr 04 17:42:07 xxx parsedmarc[2244]: raise imapclient.exceptions.IMAPClientError(error) Apr 04 17:42:07 xxx parsedmarc[2244]: imaplib.IMAP4.error: LOGIN failed Apr 04 17:42:07 xxx systemd[1]: parsedmarc.service: Main process exited, code=exited, status=1/FAILURE Apr 04 17:42:07 xxx systemd[1]: parsedmarc.service: Failed with result 'exit-code'.

My parsedmarc.ini configuration:

[general]

Save aggregate and forensic reports to Elasticsearch

save_aggregate = True save_forensic = True

[imap]

Log into the DMARC report email address and download data.

host = outlook.office365.com port = 993 ssl = True user = xxxxx password = xxxx folder = INBOX skip_certificate_verification = true watch = True

[elasticsearch]

Send data to Elastichsearch, which listens on port 9200.

hosts = 127.0.0.1:9200 ssl = False

[smtp]

For sending email

host = smtp-mail.outlook.com port = 587 ssl = True user = xxx password = xxx from = dmarc@xxx

send results to this address

to = admin@xxx

Can someone help me to fix this?

Nenigon commented 3 months ago

I already check my firewall configurations and open the ports 993/587, as well as tested my login and password.

seanthegeek commented 2 months ago

Since you are using Microsoft 365, you should use the Microsoft Graph integration instead of IMAP.

Check out the msgraph section of the configuration documentation for more details.

PerryCodes commented 2 months ago

Does msgraph work better than IMAP+DavMail?