fix(config): make the SMTP port match the implicit-TLS transport - #328
Merged
Merged
Conversation
63fc76f switched the sender from STARTTLS to implicit TLS (`SmtpTransport::relay`) and its message says "port changed to 465", but its diff only touched prose: both port-carrying values stayed 587 — `config/config.example.toml`'s sample draft and `config.rs::default_smtp_port()`. Copying the sample (`ensure_config` writes it to `<ATP_DATA_DIR>/config.toml` on first start, and `DEFAULT_CONFIG` embeds the same file) or omitting the key (serde default) therefore pairs 587 with an implicit-TLS transport: the client starts a TLS handshake on the STARTTLS port, Gmail answers in clear text and rustls reports InvalidContentType, so the verification mail is never delivered (registration returns 502). Both carriers now say 465, and `config.rs` names the mechanism so the next protocol change updates the value instead of only the prose. New test-only gate `src/smtp_port_gate.rs` derives the expected port from the transport mode in `mail.rs` (`SmtpTransport::relay` -> lettre's `SUBMISSIONS_PORT`, `builder_dangerous` -> `SUBMISSION_PORT`) rather than hardcoding it, so switching protocols demands both carriers follow.
Owner
Author
|
Self-review (committer; GitHub does not let me approve my own PR). Scope: two values that carry the SMTP port, plus a gate that keeps them equal to the port the transport mode requires. No production behaviour changes beyond the port default. Checked
Not in scope / explicitly not claimed
Merging since CI is green and the change is self-contained. |
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.
Summary
63fc76fd(2026-08-20) switched the sender from STARTTLS to implicit TLS (SmtpTransport::relay), because a TLS handshake against the STARTTLS port (587) makes the server answer in clear text and rustls fails withInvalidContentType. Its message says "port changed to 465", but the diff only touched prose: both values that actually carry the port stayed at 587 — the sample draft inconfig/config.example.tomlandconfig.rs::default_smtp_port().So both ways a user can pick up that number still give 587:
ensure_config(src/main.rs) copiesconfig/config.example.tomlto<ATP_DATA_DIR>/config.tomlon first start, andDEFAULT_CONFIGembeds the same file for standalone binaries — uncommenting the[mail]block therefore reproduces exactly the failure63fc76fdset out to fix;#[serde(default = "default_smtp_port")]supplies 587 whensmtp_portis omitted.Either way the verification mail is never delivered (registration answers 502), and nothing tells the operator that the port is the problem.
Related Issue
No issue — found while auditing value carriers; nothing tracks it.
Changes
config/config.example.toml— samplesmtp_port = 587→465, matching the paragraph five lines above it, which has said "implicit TLS → port 465" since63fc76fd.src/config.rs—default_smtp_port()returns465, and its doc comment now names the mechanism (mail.rspicks the transport mode;relay= implicit TLS = 465) so the next protocol change updates the value instead of only the prose.src/smtp_port_gate.rs(new, test-only, zero new dependencies) — keeps both carriers equal to the port the transport mode requires:mail.rs's code (SmtpTransport::relay(→ implicit TLS,builder_dangerous(→ STARTTLS) and the port from lettre's own constants (SUBMISSIONS_PORT/SUBMISSION_PORT), so switching to STARTTLS makes the gate demand 587;.tomlsample is a comment line (comments must be read), whilemail.rsmust have its comments masked first (its header prose mentionsbuilder_dangerous, which would otherwise be read as code);src/main.rs—#[cfg(test)] mod smtp_port_gate;.Tests
cargo test— 429 passed / 0 failed (baseline 426; +3 new)cargo fmt --check— cleancargo clippy --all-targets -- -D warnings— cleanA/B, reverting only the two carriers to their pre-fix values while keeping the gate:
config/config.example.toml:33 ... 587, should be 465andsrc/config.rs:71 ... 587, should be 465.tomlreverted.tomlcarrier ⇒ each rule has its own teethThe two non-axis tests stay green in every leg, as they should (they judge the scanner, not the values).
Checklist
fix/…)