Skip to content

fix(imap): STARTTLS for non-993 ports - #1690

Open
kawacukennedy wants to merge 1 commit into
floatpane:masterfrom
kawacukennedy:fix/imap-tls-mode
Open

kawacukennedy wants to merge 1 commit into
floatpane:masterfrom
kawacukennedy:fix/imap-tls-mode

Conversation

@kawacukennedy

@kawacukennedy kawacukennedy commented Jul 20, 2026 •

Copy link
Copy Markdown
Contributor

What?

Use STARTTLS for all non-993 IMAP ports, matching the SMTP path logic.

Why?

Fixes #1688

Matcha previously only used STARTTLS on ports 1143 and 143, falling back to implicit TLS on every other port. This broke local IMAP bridges (e.g. Proton Mail Bridge) that serve IMAP on non-standard ports with STARTTLS. Port 993 uses implicit TLS; all other ports now correctly use STARTTLS.

@kawacukennedy
kawacukennedy requested a review from a team as a code owner July 20, 2026 00:44
@floatpanebot floatpanebot added the area/fetcher IMAP fetch / IDLE / search label Jul 20, 2026
@kawacukennedy kawacukennedy changed the title fix(imap): use STARTTLS for all non-993 ports fix(imap): STARTTLS for non-993 ports Jul 20, 2026
@floatpanebot floatpanebot added the size/S Diff: 11–50 lines label Jul 20, 2026
@floatpanebot

floatpanebot commented Jul 20, 2026 •

Copy link
Copy Markdown
Member

Benchmark report — no significant change

Metrics worse: 0 · better: 0 (threshold: ±3%).

benchstat output
goos: linux
goarch: amd64
pkg: github.com/floatpane/matcha/backend
cpu: AMD EPYC 7763 64-Core Processor                
                           │    old.txt    │               new.txt               │
                           │    sec/op     │    sec/op      vs base              │
ParseSearchQuery_Simple-4    2.787µ ± 880%   3.231µ ± 181%       ~ (p=0.937 n=6)
ParseSearchQuery_Complex-4   7.572µ ± 140%   7.467µ ± 105%       ~ (p=0.699 n=6)
TokenizeSearchQuery-4        5.559µ ± 135%   4.505µ ± 140%       ~ (p=0.485 n=6)
geomean                      4.895µ          4.772µ         -2.51%

                           │  old.txt   │              new.txt               │
                           │    B/op    │    B/op     vs base                │
ParseSearchQuery_Simple-4    26.00 ± 0%   26.00 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   762.0 ± 0%   762.0 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        176.0 ± 0%   176.0 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      151.6        151.6       +0.00%
¹ all samples are equal

                           │  old.txt   │              new.txt               │
                           │ allocs/op  │ allocs/op   vs base                │
ParseSearchQuery_Simple-4    2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=6) ¹
ParseSearchQuery_Complex-4   23.00 ± 0%   23.00 ± 0%       ~ (p=1.000 n=6) ¹
TokenizeSearchQuery-4        9.000 ± 0%   9.000 ± 0%       ~ (p=1.000 n=6) ¹
geomean                      7.453        7.453       +0.00%
¹ all samples are equal

pkg: github.com/floatpane/matcha/tui
                    │   old.txt    │               new.txt               │
                    │    sec/op    │    sec/op      vs base              │
LogPanelView-4        159.6µ ± 17%    178.0µ ± 10%       ~ (p=0.065 n=6)
SearchOverlayView-4   161.5µ ±  5%    176.5µ ±  9%  +9.30% (p=0.002 n=6)
InboxConstruction-4   945.1µ ± 23%   1031.0µ ±  9%       ~ (p=0.093 n=6)
geomean               289.9µ          318.8µ        +9.97%

                    │    old.txt    │                new.txt                │
                    │     B/op      │      B/op       vs base               │
LogPanelView-4        44.67Ki ± 51%   21.80Ki ± 105%        ~ (p=0.459 n=6)
SearchOverlayView-4   56.15Ki ± 41%   44.67Ki ±  26%        ~ (p=0.504 n=6)
InboxConstruction-4   874.5Ki ±  0%   874.4Ki ±   0%        ~ (p=0.513 n=6)
geomean               129.9Ki         94.78Ki         -27.05%

                    │   old.txt   │              new.txt              │
                    │  allocs/op  │  allocs/op   vs base              │
LogPanelView-4         714.0 ± 0%    713.0 ± 0%       ~ (p=0.567 n=6)
SearchOverlayView-4    926.0 ± 0%    925.0 ± 0%       ~ (p=0.545 n=6)
InboxConstruction-4   3.484k ± 0%   3.482k ± 0%       ~ (p=0.416 n=6)
geomean               1.321k        1.319k       -0.10%

auto-generated by benchmarks.yml

@kawacukennedy
kawacukennedy force-pushed the fix/imap-tls-mode branch 2 times, most recently from a920630 to f362d30 Compare July 20, 2026 08:02
@floatpanebot floatpanebot added the ci CI / build pipeline label Jul 20, 2026
@floatpanebot floatpanebot added the size/M Diff: 51–200 lines label Jul 20, 2026
@floatpanebot floatpanebot added the stale No activity for extended period label Sep 3, 2026
@floatpanebot

Copy link
Copy Markdown
Member

This has had no activity for 45 days. It will be closed in 21 days unless updated. Comment or remove the stale label to keep it open.

@kawacukennedy

Copy link
Copy Markdown
Contributor Author

Hi @andrinoff — this PR is still open and all CI checks are green; just keeping it off the stale queue. Happy to rebase/adjust if anything needs updating. Thanks!

@floatpanebot floatpanebot removed the stale No activity for extended period label Sep 5, 2026
@floatpanebot floatpanebot added the stale No activity for extended period label Oct 20, 2026
@floatpanebot

Copy link
Copy Markdown
Member

This has had no activity for 45 days. It will be closed in 21 days unless updated. Comment or remove the stale label to keep it open.

@kawacukennedy

Copy link
Copy Markdown
Contributor Author

Rebased onto the new v1.0.0 master to clear the conflict. The change re-applies cleanly to the restructured fetcher/fetcher.go:

  • Port 993 keeps implicit TLS.
  • All other ports try DialStartTLS first (supports local bridges like Proton Mail Bridge) and fall back to implicit TLS if STARTTLS is refused (e.g. GreenMail on 3993).
  • Updated the in-tree test server to actually exercise the STARTTLS handshake.

go build ./..., go vet, make test and golangci-lint are green locally, and the PR is now MERGEABLE.

@kawacukennedy

Copy link
Copy Markdown
Contributor Author

CI note: the only failing check here is govulncheck, and it's a pre-existing issue on master (not caused by this PR). A new Go stdlib advisory, GO-2026-6809, was published after go 1.26.9 and is fixed in go 1.26.10; the repo still pins 1.26.9.

I've opened #1749 to bump the toolchain (also reachable via fetch → pkcs7 → x509). Once that lands, this PR's govulncheck will go green. Everything else in the matrix is passing.

@floatpanebot floatpanebot removed the stale No activity for extended period label Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/fetcher IMAP fetch / IDLE / search ci CI / build pipeline size/M Diff: 51–200 lines size/S Diff: 11–50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IMAP forces implicit TLS on any port except 1143/143 — breaks Proton Mail Bridge on non-default ports

2 participants