Skip to content

OpenStock is an open-source alternative to expensive market platforms. Track real-time prices, set personalized alerts, and explore detailed company insights — built openly, for everyone, forever free.

fix: make email configuration optional end to end

ravixalgorithmc2e10673122e
diff --git a/README.md b/README.md
index de3d7ea..0b310bb 100644
--- a/README.md
+++ b/README.md
@@ -145,7 +145,7 @@ Prerequisites
- Node.js 20+ and pnpm or npm
- MongoDB connection string (MongoDB Atlas or local via Docker Compose)
- Finnhub API key (free tier supported; real-time may require paid)
-- Gmail account for email (or update Nodemailer transport)
+- Optional: Gmail account for email (or update Nodemailer transport) if you want welcome and news summary emails
- Optional: Google Gemini API key (for AI-generated welcome intros)
Clone and install
@@ -219,6 +219,7 @@ Notes
- The app service depends_on the mongodb service.
- Credentials are defined in Compose for the MongoDB root user; authSource=admin is required on the connection string for root.
- Data persists across restarts via the docker volume.
+- `NODEMAILER_EMAIL` and `NODEMAILER_PASSWORD` are optional for local Docker runs. If they are omitted, the app still starts but email features stay disabled.
Optional: Example MongoDB service definition used in this project:
```yaml
@@ -297,9 +298,9 @@ GOOGLE_CLIENT_SECRET=your_google_client_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
-# Email (Nodemailer via Gmail; consider App Passwords if 2FA)
-NODEMAILER_PASSWORD=your_gmail_app_password
+# Email (optional; Nodemailer via Gmail, consider App Passwords if 2FA)
+# NODEMAILER_PASSWORD=your_gmail_app_password
```
Local (Docker Compose) MongoDB:
@@ -351,15 +352,16 @@ GOOGLE_CLIENT_SECRET=your_google_client_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
-# Email (Nodemailer via Gmail; consider App Passwords if 2FA)
-NODEMAILER_PASSWORD=your_gmail_app_password
+# Email (optional; Nodemailer via Gmail, consider App Passwords if 2FA)
+# NODEMAILER_PASSWORD=your_gmail_app_password
```
Notes
- Keep private keys server-side whenever possible.
- If using `NEXT_PUBLIC_` variables, remember they are exposed to the browser.
- In production, prefer a dedicated SMTP provider over a personal Gmail.
+- If the Nodemailer credentials are omitted, the app still runs but welcome and news summary emails are disabled.
- Do not hardcode secrets in the Dockerfile; use `.env` and Compose.
## 🧱 Project Structure <a name="project-structure"></a>
diff --git a/lib/inngest/functions.ts b/lib/inngest/functions.ts
index 3537849..4986d6d 100644
--- a/lib/inngest/functions.ts
+++ b/lib/inngest/functions.ts
@@ -29,7 +29,7 @@ export const sendSignUpEmail = inngest.createFunction(
}
});
- await step.run('send-welcome-email', async () => {
+ const emailResult = await step.run('send-welcome-email', async () => {
try {
const { data: { email, name } } = event;
@@ -37,6 +37,10 @@ export const sendSignUpEmail = inngest.createFunction(
console.log(`📧 Attempting to send welcome email to: ${email}`);
const result = await sendWelcomeEmail({ email, name, intro: introText });
+ if (result.status !== 'sent') {
+ console.log(`Welcome email skipped for: ${email}`);
+ return result;
+ }
console.log(`✅ Welcome email sent successfully to: ${email}`);
return result;
} catch (error) {
@@ -45,10 +49,9 @@ export const sendSignUpEmail = inngest.createFunction(
}
})
- return {
- success: true,
- message: 'Welcome email sent successfully'
- }
+ return emailResult.status === 'sent'
+ ? { success: true, message: 'Welcome email sent successfully' }
+ : { success: true, message: 'Welcome email skipped because email credentials are not configured' };
}
)
diff --git a/scripts/check-env.mjs b/scripts/check-env.mjs
index f029ffe..e1378e7 100644
--- a/scripts/check-env.mjs
+++ b/scripts/check-env.mjs
@@ -35,9 +35,6 @@ const requiredVars = {
// Inngest (Background jobs, cron, AI)
'INNGEST_SIGNING_KEY': 'Inngest signing key (required for Vercel deployment; get from Inngest dashboard)',
- // Email (Nodemailer via Gmail)
- 'NODEMAILER_EMAIL': 'Gmail address for sending emails',
- 'NODEMAILER_PASSWORD': 'Gmail app password (use App Passwords if 2FA enabled; not your regular password)',
};
/**
@@ -45,6 +42,10 @@ const requiredVars = {
* These are checked and reported but won't cause failure.
*/
const optionalVars = {
+ // Email (Nodemailer via Gmail). Without it the app runs; welcome and news emails are disabled.
+ 'NODEMAILER_EMAIL': 'Gmail address for sending emails',
+ 'NODEMAILER_PASSWORD': 'Gmail app password (use App Passwords if 2FA enabled; not your regular password)',
+
// AI Providers (for Inngest workflows)
'GEMINI_API_KEY': 'Google Gemini API key (for AI-powered welcome emails and news summaries)',