Fix: IMAP over SSL connected without TLS; never lose a sent message's copy
v1.3.26's IMAP4_SSL subclass put its create_client ahead of aioimaplib's,
which is where the TLS context is made — so port 993 got plain TCP, the
server waited for a handshake, and every SSL account timed out ("Can't
reach the mail server"). The context is now made in our create_client too,
and a test checks an SSL client really gets one (it fails without the fix).
With IMAP down, a send could still be delivered by SMTP while filing its copy
in Sent failed — the send then counted as done and the copy was lost. The
copy is now kept and filed by file_sent_copy_job, retried (arq Retry) for
about 24 hours, then shown in Sent as usual.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
import contextlib
|
||||
import re
|
||||
import ssl
|
||||
from collections.abc import AsyncIterator
|
||||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
@@ -67,6 +68,11 @@ class _KeepConnectTask:
|
||||
def create_client( # type: ignore[no-untyped-def]
|
||||
self, host, port, loop, conn_lost_cb=None, ssl_context=None
|
||||
) -> None:
|
||||
# This replaces IMAP4_SSL.create_client too (it comes first in the MRO),
|
||||
# so do its one job here: without a context the connection is plain
|
||||
# TCP to port 993, and the server just waits for a TLS handshake.
|
||||
if ssl_context is None and isinstance(self, aioimaplib.IMAP4_SSL):
|
||||
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
|
||||
local_loop = loop if loop is not None else asyncio.get_running_loop()
|
||||
self.protocol = aioimaplib.IMAP4ClientProtocol(local_loop, conn_lost_cb)
|
||||
self.connect_task = local_loop.create_task(
|
||||
|
||||
Reference in New Issue
Block a user