Skip to content

gh-108280: Give a meaningful error for an invalid imaplib greeting#152768

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-invalid-greeting
Jul 2, 2026
Merged

gh-108280: Give a meaningful error for an invalid imaplib greeting#152768
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-invalid-greeting

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 1, 2026

Copy link
Copy Markdown
Member

Connecting imaplib to a server that does not send a valid IMAP4 greeting
-- for example a POP3 server answering on the IMAP port -- failed with the
unhelpful imaplib.IMAP4.error: None.

A +OK ... greeting matches the continuation response pattern, so
_get_response() returns None and self.welcome is left as None. The
error now reports the greeting the server actually sent, e.g.
invalid greeting: +OK POP3 server ready, so it is clear the peer is not an
IMAP server. An untagged greeting such as * BYE ... is reported likewise,
and a bare continuation with no text yields invalid greeting from server.

Connecting to a server that does not send a valid IMAP4 greeting, such as
a POP3 server answering on the IMAP port, failed with the unhelpful
"imaplib.IMAP4.error: None".  A meaningful message is now raised instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@serhiy-storchaka serhiy-storchaka requested a review from a team as a code owner July 1, 2026 10:46
@bedevere-app bedevere-app Bot mentioned this pull request Jul 1, 2026
2 tasks
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jul 1, 2026
@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) July 2, 2026 07:14
@serhiy-storchaka serhiy-storchaka merged commit 262b6a0 into python:main Jul 2, 2026
59 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152856 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 2, 2026
@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152857 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jul 2, 2026
@bedevere-app

bedevere-app Bot commented Jul 2, 2026

Copy link
Copy Markdown

GH-152858 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 2, 2026
@serhiy-storchaka serhiy-storchaka deleted the imaplib-invalid-greeting branch July 2, 2026 07:16
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…ting (GH-152768) (GH-152858)

Connecting to a server that does not send a valid IMAP4 greeting, such as
a POP3 server answering on the IMAP port, failed with the unhelpful
"imaplib.IMAP4.error: None".  A meaningful message is now raised instead.
(cherry picked from commit 262b6a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…ting (GH-152768) (GH-152857)

Connecting to a server that does not send a valid IMAP4 greeting, such as
a POP3 server answering on the IMAP port, failed with the unhelpful
"imaplib.IMAP4.error: None".  A meaningful message is now raised instead.
(cherry picked from commit 262b6a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
serhiy-storchaka added a commit that referenced this pull request Jul 2, 2026
…ting (GH-152768) (GH-152856)

Connecting to a server that does not send a valid IMAP4 greeting, such as
a POP3 server answering on the IMAP port, failed with the unhelpful
"imaplib.IMAP4.error: None".  A meaningful message is now raised instead.
(cherry picked from commit 262b6a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant