Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imaplib.IMAP4.error: LOGIN failed #506

Open
Nenigon opened this issue Apr 4, 2024 · 6 comments
Open

imaplib.IMAP4.error: LOGIN failed #506

Nenigon opened this issue Apr 4, 2024 · 6 comments

Comments

@Nenigon
Copy link

Nenigon commented Apr 4, 2024

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
Copy link
Author

Nenigon commented Apr 4, 2024

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

@seanthegeek
Copy link
Contributor

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
Copy link

Does msgraph work better than IMAP+DavMail?

@ijeries
Copy link

ijeries commented Aug 16, 2024

I had a similar error to the above.
The issue was with IMAP not being enabled by default on the free outlook.com account i was using (free [previously hotmail.com], not business paid for service).

Fix was as follows:

  1. Enable IMAP - logon to the mailbox via a web browser and navigate to: Settings ==> Email ==> Forwarding and IMAP ==> Sign in button ==> Enabled IMAP under the "POP and IMAP" section.
    POP option left disabled should anyone wish to know.

  2. Setup the account in Thunderbird. Servers to purposes, may not be strictly required but i did):
    2.a) To confirm the IMAP connection is possible and get the correct IMAP server ( under Thunderbird account settings) address. The server details are auto discovered, so should be correct.
    2.b) Allow app access to the mailbox via IMAP - manual step, a pop-up appears during the setup, click "Allow"

  3. Restarted the parsedmarc service, the error should disappear + ParseDMARC should start processing reports.

My current and working IMAP config:

[imap]
host = outlook.office365.com
ssl = True
port = 993
user = @outlook.com
password =

I hope this helps someone out there.

@Pascal76
Copy link

Pascal76 commented Aug 16, 2024

I am not sure this will work after the 16th of september as Microsoft will not allow connexions using only a login/password.

@ijeries
Copy link

ijeries commented Aug 16, 2024

Many thanks @Pascal76, i wasn't aware of this, will move move away from it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants