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:
2026-10-05 22:24:23 +02:00
co-authored by Claude Opus 5.5
parent 609e7c58f9
commit bfe011cd2c
5 changed files with 100 additions and 9 deletions
+2 -1
View File
@@ -15,7 +15,7 @@ from typing import Any
from arq import func
from app.outbox.draft_sync import push_draft_to_imap_job, remove_imap_draft_job
from app.outbox.jobs import send_job
from app.outbox.jobs import file_sent_copy_job, send_job
from app.sync.actions import (
ACTION_MAX_TRIES,
delete_thread_job,
@@ -48,6 +48,7 @@ _RETRYING_ACTIONS: list[Any] = [
restore_thread_job,
delete_thread_job,
empty_folder_job,
file_sent_copy_job,
]
INTERACTIVE_FUNCTIONS: list[Any] = [