Make email configuration optional
Summary
- stop initializing and verifying the Nodemailer transporter when email credentials are missing
- keep welcome and news summary emails disabled until NODEMAILER_EMAIL and NODEMAILER_PASSWORD are set
- clarify in the README that the email variables are optional for local and Docker setups
Test plan
- npx eslint lib/nodemailer/index.ts
- npx tsc --noEmit (currently fails on pre-existing errors in lib/inngest/functions.ts; not caused by this change)
Fixes Open-Dev-Society/OpenStock#37
Summary by CodeRabbit
-
Documentation
- Marked email credentials as optional in configuration and Docker notes; example env entries commented out.
- Clarified that welcome and news summary emails are disabled when credentials are omitted.
-
Bug Fixes
- App now starts without email creds and logs clear warnings instead of erroring; email sends are skipped gracefully when not configured.
- Email send operations and signup flow now return/propagate explicit "sent" vs "skipped" statuses so skipped emails are handled predictably.
@keshav-005 is attempting to deploy a commit to the ravixalgorithm's projects Team on Vercel.
A member of the Team first needs to authorize it.
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 43159aab-fe2b-4f85-9d55-2168ac016026
π₯ Commits
Reviewing files that changed from the base of the PR and between 04b5a27bf9ded2b74e2be0bb5e7a65425f1b7c22 and 101411d9d66a5f0e64ff03b6cfec419ec017ef7b.
π Files selected for processing (2)
lib/inngest/functions.tslib/nodemailer/index.ts
π§ Files skipped from review as they are similar to previous changes (1)
- lib/nodemailer/index.ts
π Walkthrough
Walkthrough
The PR makes Nodemailer/Gmail credentials optional: the app can start without NODEMAILER_EMAIL/NODEMAILER_PASSWORD; when absent, transporter is null and welcome/news emails are skipped (returning a status), and README + Docker notes updated to document this behavior.
Changes
| Cohort / File(s) | Summary |
|---|---|
Documentation README.md |
Clarified that NODEMAILER_EMAIL/NODEMAILER_PASSWORD are optional; commented out those vars in examples; added Docker note that omission won't prevent startup and will disable welcome/news emails. |
Email Configuration lib/nodemailer/index.ts |
Introduced hasEmailConfig; export const transporter now `nodemailer.Transporter |
Event Function lib/inngest/functions.ts |
sendSignUpEmail captures send-welcome-email result, logs/skips when status !== 'sent', and adjusts final return message based on emailResult.status. |
Sequence Diagram(s)
sequenceDiagram
autonumber
participant User
participant Inngest as Inngest Function
participant App as App/Server
participant Nodemailer as Nodemailer/SMTP
User->>App: POST /signup (create account)
App->>Inngest: trigger send-welcome-email step
Inngest->>Nodemailer: request sendWelcomeEmail
alt transporter exists
Nodemailer->>Nodemailer: send email via SMTP
Nodemailer-->>Inngest: { status: "sent", messageId }
Inngest-->>App: continue with "email sent" path
else transporter missing
Nodemailer-->>Inngest: { status: "skipped" }
Inngest-->>App: continue with "email skipped" path (logged)
end
App-->>User: respond with signup result
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~25 minutes
Possibly related PRs
- Open-Dev-Society/OpenStock#32 β modifies
lib/nodemailer/index.tsand sendWelcome/sendNews behavior; directly overlaps transporter/credentials handling. - Open-Dev-Society/OpenStock#8 β earlier change to
lib/nodemailer/index.tsthat introduced transporter behavior now adjusted here; relevant to return-shape and initialization differences.
Poem
π°
I sniffed the env and twitch my nose,
If creds are gone, I tiptoe slow.
The app still hops, the logs can say,
"Emails paused β theyβll wake one day." β¨π§
π₯ Pre-merge checks | β 5
β Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title 'Make email configuration optional' directly and concisely describes the main change across all modified files. |
| Linked Issues check | β Passed | The PR fully addresses issue #37 by making email initialization conditional, preventing errors when credentials are absent, and documenting email as optional. |
| Out of Scope Changes check | β Passed | All changes directly support the objective of making email configuration optional with no unrelated modifications detected. |
| Docstring Coverage | β Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Thanks, updated. Missing email config now skips sends cleanly, and the optional .env examples are commented out so copy-paste preserves the disabled-email path.
Thanks, updated. The mailer now returns an explicit skipped/sent result, and the signup flow only logs and reports success when a welcome email is actually sent.