fix(email): derive SMTP secure mode from credentials #76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "exe-dev-bot/market:refactor/smtp-explicit-secure-flag"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Newsletter delivery fails in production with:
The SMTP code auto-detected STARTTLS and AUTH from the server's EHLO response. Many SMTP servers only advertise
AUTHafter the TLS upgrade, butsupportsAuthwas captured from the pre-TLS EHLO and never re-evaluated.Solution
Remove capability auto-detection. Instead, derive secure mode from whether SMTP credentials are provided:
user+pass): STARTTLS + AUTH LOGIN (production)This requires no new env vars or flags. For local dev,
SMTP_USERandSMTP_PASSare left empty in.env.Changes
src/lib/email.ts: Remove EHLO capability parsing; derivesecurefrom!!(user && pass).env/.env.example: Clear local SMTP credentialsTesting
wrangler dev→ emails delivered to Mailpit (plain TCP, no TLS/AUTH)refactor(email): replace SMTP auto-detection with import.meta.env.PRODto fix(email): derive SMTP secure mode from credentials