fix: harden mailer transport selection and fallbacks - #1402
Open
kaizercodes wants to merge 4 commits into
Open
kaizercodes wants to merge 4 commits into
kaizercodes wants to merge 4 commits into
Conversation
|
@kaizercodes Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Overview
This PR hardens the transport selection and fallback logic in
src/lib/mailer.tsso that disabled, console, SMTP, and missing-nodemailer paths behave predictably and observably. The mailer is on the critical path for quota and invoice notifications, so silent or ambiguous fallback behavior is a real risk; this change makes each branch explicit and logs the outcome through the shared logger.Related Issue
Changes
📬 Mailer transport selection and fallbacks
src/lib/mailer.tssendMailcontrol flow so each transport mode is handled in a single, explicit branch:src/logger.ts.nodemailer, constructs the transporter, and callstransporter.sendMailwithfrom,to, andsubject(plus body) populated from the message.configureMailerentry point as the single place to toggle modes, so behavior is driven by configuration rather than ad-hoc branching.Verification Results
Manual review of each branch in
src/lib/mailer.tsconfirms:transporter.sendMailwithfrom/to/subject.nodemailerfalls back to console and logs a warning.transporter.sendMailwith from/to/subjectsendMail({ from, to, subject, ... })Security and Failure-Mode Handling
nodemailerpath emits a warning, so operators can detect that SMTP delivery has degraded to console instead of discovering dropped customer emails after the fact.Compatibility
configureMailerandsendMailkeep their existing signatures.nodemailerremains an optional dependency resolved via dynamic import; environments without it continue to work through the console fallback.Closes #1295