Fix POP3/SMTP correctness and IMAP robustness #10

Merged
lyrathorpe merged 2 commits from fix/pop3-smtp-correctness into main 2026-06-17 17:33:10 +01:00
Owner

POP3/SMTP proxy correctness fixes.

  • RETR now returns the message body (reads the FETCH tuple). Closes #1
  • Maildrop snapshotted once; DELE marks survive STAT/LIST/UIDL. Closes #2
  • RETR/TOP dot-stuff and CRLF-terminate per RFC 1939. Closes #3
  • SMTP relays raw bytes, no UTF-8 mangling. Closes #4
  • Message sizes batched in one IMAP round-trip off the event loop; IMAP timeout added. Closes #5
  • POP3 TOP implemented. Closes #6

pytest: 10 passed.

POP3/SMTP proxy correctness fixes. - RETR now returns the message body (reads the FETCH tuple). Closes #1 - Maildrop snapshotted once; DELE marks survive STAT/LIST/UIDL. Closes #2 - RETR/TOP dot-stuff and CRLF-terminate per RFC 1939. Closes #3 - SMTP relays raw bytes, no UTF-8 mangling. Closes #4 - Message sizes batched in one IMAP round-trip off the event loop; IMAP timeout added. Closes #5 - POP3 TOP implemented. Closes #6 pytest: 10 passed.
lyrathorpe added 2 commits 2026-06-17 17:22:53 +01:00
Fix several POP3/IMAP proxy correctness defects:

- RETR returned an empty body because fetch_message kept only top-level
  bytes from the imaplib FETCH response; extract the RFC822 literal from
  the response tuple instead.
- DELE marks were wiped mid-session because STAT/LIST/UIDL refreshed the
  mailbox and cleared the deleted set. Snapshot the UID list once at
  authentication and keep the maildrop static for the session lifetime.
- RETR/TOP output now normalises line endings to CRLF, byte-stuffs lines
  beginning with ".", and emits the terminating ".\r\n" per RFC 1939.
- STAT/LIST batch message sizes via a single threaded UID FETCH and the
  IMAP client now uses a 30s socket timeout, keeping blocking work off the
  event loop.
- Implement the POP3 TOP command (headers plus first n body lines).

Fixes #1
Fixes #2
Fixes #3
Fixes #5
Fixes #6

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
fix: relay raw SMTP bytes without decoding
Build and publish container / build (pull_request) Successful in 9m6s
df19c60b17
send_message decoded the message body with utf-8/errors="replace",
corrupting 8-bit content before forwarding. Pass the raw bytes straight
to smtp.sendmail so the message is relayed unchanged.

Fixes #4

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lyrathorpe merged commit bde999185a into main 2026-06-17 17:33:10 +01:00
lyrathorpe deleted branch fix/pop3-smtp-correctness 2026-06-17 17:33:12 +01:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lyrathorpe/legacy-email-proxy#10