Skip to content

Make email configuration optional#69

Open
keshav-005 wants to merge 3 commits into
Open-Dev-Society:mainfrom
keshav-005:fix-37-optional-email-config
Open

Make email configuration optional#69
keshav-005 wants to merge 3 commits into
Open-Dev-Society:mainfrom
keshav-005:fix-37-optional-email-config

Conversation

@keshav-005
Copy link
Copy Markdown
Contributor

@keshav-005 keshav-005 commented Apr 22, 2026

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 #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.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 22, 2026

@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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

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 04b5a27 and 101411d.

📒 Files selected for processing (2)
  • lib/inngest/functions.ts
  • lib/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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • added donation #32 — modifies lib/nodemailer/index.ts and sendWelcome/sendNews behavior; directly overlaps transporter/credentials handling.
  • implement auth logic #8 — earlier change to lib/nodemailer/index.ts that 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/nodemailer/index.ts`:
- Around line 34-38: The sendWelcomeEmail function currently throws when
transporter is null which causes callers to treat email as a failure; change it
to skip silently (or return a resolved value) when transporter is not configured
instead of throwing: in sendWelcomeEmail (and the similar function around lines
61-67) replace the throw new Error('Email credentials not configured') with an
early return/no-op (optionally logging a debug/info message) so the function
resolves successfully when transporter is null and only attempts to send when
transporter exists.

In `@README.md`:
- Around line 277-280: The README's .env example sets NODEMAILER_EMAIL and
NODEMAILER_PASSWORD to literal placeholders which makes hasEmailConfig evaluate
true and incorrectly trigger Gmail transporter initialization; update the .env
examples (including the block around NODEMAILER_EMAIL/NODEMAILER_PASSWORD and
the similar block at lines 318-321) to comment out or remove those optional
lines so they are not inadvertently set by copy-paste, and ensure the docs
explicitly show them commented/unset to preserve the “omitted credentials” path
used by the code that checks hasEmailConfig.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e1869f6-fd84-46c5-9a79-cf7ae0183975

📥 Commits

Reviewing files that changed from the base of the PR and between fe59884 and 7121b57.

📒 Files selected for processing (2)
  • README.md
  • lib/nodemailer/index.ts

Comment thread lib/nodemailer/index.ts
Comment thread README.md
@keshav-005
Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/nodemailer/index.ts`:
- Around line 36-39: The callers of sendWelcomeEmail (the send-welcome-email
step in lib/inngest/functions.ts) are logging success unconditionally even when
lib/nodemailer/index.ts returns null because transporter is not configured;
update either sendWelcomeEmail to return a discriminated result (e.g., {
skipped: true } | { success: true, info: ... }) instead of null, or update the
caller(s) (send-welcome-email and the news-summary caller) to check the return
value from sendWelcomeEmail and only log "✅ Welcome email sent successfully"
when a success result is returned; reference the transporter check in
lib/nodemailer/index.ts and the sendWelcomeEmail invocation in
lib/inngest/functions.ts to locate the spots to change.
- Line 37: Replace the double-encoded mojibake sequence in the warning messages
with the proper warning emoji "⚠️" in the console.warn calls in this module
(both occurrences currently showing "âš ï¸�" — e.g., the console.warn that logs
"Welcome email skipped: email credentials are not configured." and the other
similar warning later in the file). Update both console.warn strings to include
"⚠️" exactly and save the file with UTF-8 encoding to prevent reintroducing the
encoding issue.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f1adfa07-74fb-4e1e-b871-da58f7d4b8f5

📥 Commits

Reviewing files that changed from the base of the PR and between 7121b57 and 04b5a27.

📒 Files selected for processing (2)
  • README.md
  • lib/nodemailer/index.ts
✅ Files skipped from review due to trivial changes (1)
  • README.md

Comment thread lib/nodemailer/index.ts
Comment thread lib/nodemailer/index.ts Outdated
@keshav-005
Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NODEMAILER_EMAIL or NODEMAILER_PASSWORD is not set. Email functionality will not work

1 participant