Repository navigation
COR-237 - Close the connection after an SMTP account check - #118
Merged
Merged
Conversation
Collaborator
Author
|
bugbot run |
`SMTPCheckAccountOperation` left the session connected, so the socket stayed open until the automatic disconnect 30 s later. A server that caps concurrent SMTP connections per client IP (GoDaddy's Exim allows one) then refuses the next check with `421` before TLS, which reaches the caller as `ErrorConnection`: Spark's account discovery checks the same credentials twice a few seconds apart and fails on the second. `LeaseTestTCPEndpoint` learns to answer untagged line protocols so the test can play an SMTP server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dbezverkhnii
force-pushed
the
fix/COR-237-smtp-check-disconnects
branch
from
October 7, 2026 18:24
bdb7bb7 to
f209e2f
Compare
Collaborator
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit f209e2f. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SMTPCheckAccountOperationleft the SMTP session connected after the check. The socket stayed open untilSMTPAsyncSession::tryAutomaticDisconnect, 30 s later, and the delayed call retains the session, so dropping the Swift object does not close it either.Why it matters
Some servers cap concurrent SMTP connections per client IP. Measured on a GoDaddy cPanel account (Exim):
421 Too many concurrent SMTP connectionsin plaintext before TLS;ErrorConnection.Spark's add-account flow checks the same credentials twice about 5 s apart (Verify, then Login). The second check therefore fails while the first one's socket is still open.
Change
SMTPCheckAccountOperation::maincallsdisconnect()aftercheckAccount, whatever the outcome:mSmtpis already NULL and the call does nothing;mailsmtp_quitdoes not wait on, and unsets the session;checkAccountOperationin Spark core is discovery'sIMAPChecker. The send path does not use it.Tests
SMTPCheckAccountTestsplays an SMTP server on loopback (LeaseTestTCPEndpointgains arepliesmode for untagged line protocols). It asserts that the client closes its socket within 5 s after a successful check and after a rejected sender.swift test --filter 'IMAP|SMTP|Libetpan|Certificate': 52 tests, 0 failures. The IMAP tests that use the endpoint are unchanged.Not done here
Publish-Mailcore2Prebuilt.ps1). Themailcore2 - Windows prebuiltcheck will stay red until then.🤖 Generated with Claude Code
Note
Medium Risk
Changes SMTP session lifecycle for all check-account callers; safe for discovery-style one-shot checks but adds an extra connect if the same session is reused for sending.
Overview
SMTP account checks now tear down the session immediately instead of leaving the socket open until the ~30s automatic disconnect.
SMTPCheckAccountOperation::maincallsdisconnect()aftercheckAccountcompletes, whether the check succeeds or fails, so per-IP connection limits no longer block a follow-up check (e.g. back-to-back verify/login).Test support:
LeaseTestTCPEndpointgains an optionalrepliesclosure for line-oriented protocols like SMTP. NewSMTPCheckAccountTestsassert the client closes within 5s after a successful check and after a rejected sender.Package.swiftregisters the new test file.Trade-off: Reusing the same
MCOSMTPSessionfor a check and then send now requires an extra connect.Reviewed by Cursor Bugbot for commit f209e2f. Bugbot is set up for automated code reviews on this repo. Configure here.