# Selected SMTP transport remediation - #4437

Status: production-based local candidate and four-relay qualification verified. Awaiting explicit live-release/test-mail approval and received-message DKIM/DMARC evidence.

Audit #4434 found both queue workers constructing an EsmtpTransport but sending through the default SendmailTransport. SelectedSmtpTransportFactory retains the original host, port, TLS and credential contract. SelectedSmtpMailer clones the resolved default Laravel Mailer, installs the selected transport only on that clone, and runs the original synchronous callback. Cached/default mail state remains unchanged, including nested sends and exceptions. Guards, envelopes, recipients, retention and queue/retry behavior remain unchanged.

## Current production-based candidate

Production base: c13f7384b7234081a6b8b5b8e5abcf240ec7c87c on post.nuhet.se (/var/www/html). Task branch codex/4437-selected-smtp-prod; original branch codex/4437-selected-smtp-transport at4e709275 remains preserved. Production's prepared-editor/legacy newsletter view selection and html/text data were retained when integrating the routing fix. The executable production diff is four application files plus two test files; no configuration, dependency, migration, DNS or relay changes.

[Current verification](selected-smtp-4437/production-verification.json) binds exact hashes, commands and original runner output. PHP8.4.27, locked Laravel12.70.1, SymfonyMailer7.4.15/Mime7.4.16/PHPUnit11.5.56. [Final related tests](selected-smtp-4437/production-base-tests.txt):39 tests/309 assertions pass, one existing PHPUnit XML deprecation. The strengthened prepared-output case uses empty HTML and multiline text, distinguishing prepared rendering from legacy nl2br fallback. Both worker routing paths, recipients/envelope, guards, failure/retry, retention and default-mail isolation remain covered without network delivery.

[Independent production-base review](selected-smtp-4437/production-base-review.md): PASS, SHA256f0b82c1d3f2276c5bc19979c759db7d14df177aa14847802c94e8f2f4a6028e6, same independent gpt-6.1-sol medium reviewer, no implementation authorship. Root inspected the actual production diff, final test, hashes and evidence and accepts this bounded local candidate. Source/configuration checks are not received-message proof.

## Relay qualification

Native approved personal profiles Nuhet Iota/Kappa/Lambda/Mu connect as nuhet_auth_1 at85.118.203.84-87; all4 SSH logins pass. The password came from the named KeePass entry through native transport/hidden-input mechanisms and was never returned to an agent.

[Read-only qualification receipt](selected-smtp-4437/relay-qualification-pre-auth.json): all4 Postfix/OpenDKIM active milter paths and MySQL mappings point at actual Nuhet backend10.50.35.10:3306; public domainpost.nuhet.se/selectormail/key11 matches DNS. Private keys and full credential-bearing DSNs were never selected. Actual app-host TLS certificate/name validation and SMTP220 greeting pass for all4 configured private routes on465 (TLS1.3).

[Actual AUTH/QUIT receipt](selected-smtp-4437/smtp-auth-receipt.json): all4 explicitly accepted AUTH PLAIN235 and QUIT221, exit0; fresh helper pane retired. No message was submitted. Exact [probe](selected-smtp-4437/smtp-auth-probe.php)/[launch](selected-smtp-4437/smtp-auth-command.txt) passed [independent source review](selected-smtp-4437/smtp-auth-probe-review.md). Round1's false-success predicates and their correction are preserved in the historical review. Four deployed Symfony source hashes match the reviewed sources.

Observations retained without remediation: milter_default_action=accept (fail-open), duplicate myorigin warning at main.cf42 on all4, and identical first-seen ECDSA host fingerprints despite distinct verified hostnames. Qualification does not prove that any particular message was signed or that a receiver verified it.

## Concrete release decision and queue plan

No live release or synthetic mail is authorized yet. Proposed approval scope is the reviewed code-only deployment, a bounded email-only pause through existing controls, and four clearly tagged verification messages, one per enabled relay, to abuse@nuhet.se. Proposed From/envelope address: nuhet-dkim-check@post.nuhet.se. Subject: Nuhet #4437 DKIM verification - <relay>. Plain/HTML bodies identify the card, relay and one-time diagnostic purpose; no customer content. No customer/receiver/tenant records need changing for a controlled shared-transport submission. No automatic retry of an uncertain send.

Root is the sole release/queue owner. Fresh [queue preflight](selected-smtp-4437/release-preflight.json) found www-data's Nuhet schedule:run cron at line23, every minute, no flock; seven named campaign workers and one SMTP worker are scheduled with withoutOverlapping. Existing email controls are system_settings id4 allow_send=1 and id32 allow_smtp_send=1. Both queue tables were empty at the recorded snapshot; this is not a promise of later emptiness. The first process snapshot included live schedule:run/QueueMailer processes.

After approval:
1. Revalidate production identity/base, all deployment paths and the exact two control values. Preserve existing tracked config/feedback.php and config/newsletter_editor.php changes. If production has advanced or overlapping ownership appears, stop before writes and reconcile the candidate.
2. Snapshot the two control rows and queue identities/reservations, set only allow_send and allow_smtp_send to0 using a checked transaction, and fresh-read. These are existing email-send controls; retain all unrelated settings and the scheduler. Wait for existing email workers to exit naturally. Do not kill workers, clear locks/reservations or replay deliveries. Bound the pause/drain attempt to five minutes; if draining fails, restore exactly the owned original settings, verify, and do not deploy.
3. Verify the local bundle/hash and c13f prerequisite; upload by native sftp_put into a task-specific /tmp path. Use the host's documented ff-only bundle pull of the exact reviewed release ref. No production GitHub credential, composer install, config:cache, migration, broad service restart or file overwrite workaround.
4. Fresh-verify the deployed commit, four application hashes, unchanged unrelated tracked configuration and unchanged queue identities while paused. The selected transport construction remains identical; default mail remains isolated. On failure, keep ownership while reconciling, and roll back the four application paths through an explicit reviewed revert commit/bundle.
5. Restore the exact original two control values and verify them. Reconcile submissions against queue/send outcomes and eventual received Message-IDs before concluding no duplicate/missing delivery. Never reset queue state or retry an uncertain send blindly.
6. Under the separately approved test-mail scope, submit at most one labelled message per relay through the same selected factory/mailer, without automatic retries. Capture exact Message-IDs and accepted protocol results without secrets. Obtain the original received messages through Thunderbird/the person's approved original-message handoff; current supported Thunderbird tools lack raw authentication/signature-header export. Jonathan owns that manual header access unless a supported capability is established. No alternate inbox path.
7. Require trusted receiver Authentication-Results with verified DKIM d=post.nuhet.se/s=mail and DMARC alignment, Received route/relay attribution and matching Message-ID. A signature's mere presence or public-key match is insufficient. Failed/unavailable proof leaves #4437 open.

Rollback uses the same bounded email pause/drain and single owner, restores the exact pre-release application files through a descendant revert commit, preserves production configuration and queue data, then restores the saved controls. Preserve any accepted messages; no resend/reset. Automatic live rollback authority must be included in the release approval. Relay/DNS/signing/DMARC policy changes are outside this packet.

## Historical evidence

The original8052ad91-based candidate, [verification.json](selected-smtp-4437/verification.json), [38-test run](selected-smtp-4437/related-tests.txt), [baseline expected failures](selected-smtp-4437/baseline-tests.txt), [post-WSL-recovery run](selected-smtp-4437/post-recovery-tests.txt) and [original independent review](selected-smtp-4437/independent-review.md) remain historical evidence. The two unchanged pre-fix workers fail the selected-transport assertions because delivery goes to the default recording transport. The fresh production-base evidence above supersedes their candidate binding for release.

Task-owned vendor was synchronized to locked dependencies; shared dependencies remain untouched. Existing Composer ambiguous classmap warnings and PHPUnit XML deprecation are unrelated and disclosed. No broad dependency cleanup is included.

## Maintainability and ownership

QueueMailer.php is1006 lines and SMTPQueueMailer.php778. Extracting the shared transport factory addresses the duplicated defect. Later CampaignMessageBuilder.php and SmtpApiMessageBuilder.php, then queue policy, should be split one boundary at a time with recipient/envelope/guard/retry parity tests. This is advisory; no broader refactor is authorized.

Root owns the task worktree, preserved branches, local bundle and scratch retention/cleanup. Both human-owned password-recovery consoles remain unread and are the person's to close. The AUTH helper retired with exit0. The card watch expired at2026-10-28T09:33:54Z; after a human-approval wait, manual user resume is required. No new schedule or self-renewed watch.
