From 3348af292269d704536d425a5eef613272b93054 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:09:31 +0000 Subject: [PATCH 1/2] Initial plan From 433a3f972f74f6be29b7a15088ebbcbdd1b995b5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 12:13:03 +0000 Subject: [PATCH 2/2] Fix SMTP config: conditional secure flag, remove exposed credentials Co-authored-by: kulharshit21 <124128807+kulharshit21@users.noreply.github.com> Agent-Logs-Url: https://github.com/kulharshit21/Portfolio/sessions/3645e2b8-7453-4887-af8e-249657a2cc84 --- DEPLOYMENT.md | 6 +++--- netlify/functions/contact.js | 7 ++++--- server/index.js | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index e7afc77..1ef819b 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -8,7 +8,7 @@ This guide will help you deploy your portfolio to Netlify with a fully functiona 1. **GitHub Account** (to push your code) 2. **Netlify Account** (free at [netlify.com](https://netlify.com)) -3. **Gmail App Password** (already configured: `mwwi pcqj srfr drur`) +3. **Gmail App Password** (generate one at [myaccount.google.com/apppasswords](https://myaccount.google.com/apppasswords)) --- @@ -101,7 +101,7 @@ Your contact form **will NOT work** without these environment variables! | `SMTP_HOST` | `smtp.gmail.com` | | `SMTP_PORT` | `465` | | `SMTP_USER` | `kulharshit21@gmail.com` | - | `SMTP_PASS` | `mwwi pcqj srfr drur` | + | `SMTP_PASS` | `` | | `RECIPIENT` | `kulharshit21@gmail.com` | 3. **⚠️ IMPORTANT**: After adding environment variables, you MUST redeploy: @@ -156,7 +156,7 @@ Your contact form **will NOT work** without these environment variables! ### Issue 2: Emails not sending **Solution**: -- Verify Gmail App Password is correct: `mwwi pcqj srfr drur` +- Verify Gmail App Password is correct (generate a new one at [myaccount.google.com/apppasswords](https://myaccount.google.com/apppasswords)) - Ensure `SMTP_PORT` is `465` (not 587) - Check if Gmail account has "Less secure app access" enabled (if needed) diff --git a/netlify/functions/contact.js b/netlify/functions/contact.js index 9e6de2f..30b9557 100644 --- a/netlify/functions/contact.js +++ b/netlify/functions/contact.js @@ -53,10 +53,11 @@ export async function handler(event) { }; } + const smtpPort = +process.env.SMTP_PORT || 465; const transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, - port: +process.env.SMTP_PORT, - secure: true, + port: smtpPort, + secure: smtpPort === 465, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS, @@ -126,7 +127,7 @@ export async function handler(event) { body: JSON.stringify({ ok: true }), }; } catch (error) { - console.error('Contact function error:', error); + console.error('Contact function error:', error.message ?? error); return { statusCode: 500, headers, diff --git a/server/index.js b/server/index.js index ca67713..8f76f6a 100644 --- a/server/index.js +++ b/server/index.js @@ -12,10 +12,11 @@ const app = express(); app.use(cors()); app.use(express.json()); +const smtpPort = +process.env.SMTP_PORT || 465; const transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, - port: +process.env.SMTP_PORT, - secure: true, + port: smtpPort, + secure: smtpPort === 465, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS