Skip to content

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

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:imaplib-invalid-greeting
Open

gh-108280: Give a meaningful error for an invalid imaplib greeting#152768
serhiy-storchaka wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant