Merge pull request #1725 from przemub/imap-auth-plain

Use AUTHENTICATE PLAIN instead of LOGIN
This commit is contained in:
Peter Bieringer
2025-03-06 18:31:50 +01:00
committed by GitHub

View File

@@ -59,7 +59,10 @@ class Auth(auth.BaseAuth):
if self._security == "starttls":
connection.starttls(ssl.create_default_context())
try:
connection.login(login, password)
connection.authenticate(
"PLAIN",
lambda _: "{0}\x00{0}\x00{1}".format(login, password).encode(),
)
except imaplib.IMAP4.error as e:
logger.warning("IMAP authentication failed for user %r: %s", login, e, exc_info=False)
return ""