Skip to content

Conversation

@onipinaka
Copy link

@onipinaka onipinaka commented Oct 4, 2025

Description

This PR adds a welcome email feature to the Paisable application. Now, when a new user successfully registers, the backend automatically sends a friendly welcome email confirming their account creation. The email is sent using either SendGrid (if configured) or Gmail SMTP as a fallback.

Related Issue:
fixes #9

The email sending is implemented as a fire-and-forget operation, meaning it does not block or delay the user registration process. Any failures in the email service are logged, but the user account is still created and the API response is returned immediately.

Changes include:

  • Added sendEmail.js utility in backend/utils/ to handle email sending.
  • Updated signup function in authController.js to call sendWelcomeEmail after successful account creation.
  • Emails include a friendly HTML and text message with guidance on next steps in the app.
  • Supports both SendGrid API and Gmail SMTP configuration via .env.

Related Issue

Fixes #


Motivation and Context

Previously, when a new user registered, there was no confirmation or onboarding email, which could make the app feel less professional and reduce user engagement. This feature:

  • Improves user onboarding with a welcoming message.
  • Provides basic email validation (successful delivery indicates a working email).
  • Encourages users to start exploring the application immediately.

Types of Changes

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Registered new users locally and verified that:
    • API response returns correctly without delay.
    • Emails are sent to the user using configured email service.
    • Failures in email sending (e.g., incorrect API key) are logged but do not block registration.
  • Tested with both SendGrid API key and Gmail SMTP fallback.

Screenshots (if applicable):

  • N/A — backend feature only.

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@Copilot Copilot AI review requested due to automatic review settings October 4, 2025 10:12
@netlify
Copy link

netlify bot commented Oct 4, 2025

Deploy Preview for paisable ready!

Name Link
🔨 Latest commit 9a6c43c
🔍 Latest deploy log https://app.netlify.com/projects/paisable/deploys/68e54a6ad8370f0008f6647b
😎 Deploy Preview https://deploy-preview-78--paisable.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95
Accessibility: 100
Best Practices: 100
SEO: 82
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a welcome email feature to automatically send confirmation emails to new users after successful registration. The implementation uses a fire-and-forget approach to avoid blocking the registration process.

  • Added email utility with SendGrid and SMTP fallback support
  • Updated user registration to trigger welcome email sending
  • Added necessary dependencies and documentation for email configuration

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

File Description
backend/utils/sendEmail.js New email utility with SendGrid/SMTP support and welcome email template
backend/package.json Added @sendgrid/mail and nodemailer dependencies
backend/controllers/authController.js Updated signup function to send welcome email after user creation
README.md Added email configuration documentation
Files not reviewed (1)
  • backend/package-lock.json: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +51 to +56
transport.verify()
.then(() => console.info("SMTP transporter verified"))
.catch(err => console.warn("SMTP transporter verification failed", { message: err.message }));

sendRaw = async ({ to, from, subject, text, html }) => {
try {
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The SMTP transporter verification is executed asynchronously at module load time without awaiting completion. This could lead to race conditions where sendRaw attempts to use an unverified transporter. Consider moving this verification inside sendRaw or making it a blocking operation during initialization.

Suggested change
transport.verify()
.then(() => console.info("SMTP transporter verified"))
.catch(err => console.warn("SMTP transporter verification failed", { message: err.message }));
sendRaw = async ({ to, from, subject, text, html }) => {
try {
// Ensure transporter is verified before sending emails
let smtpVerified = false;
let smtpVerifyPromise = null;
sendRaw = async ({ to, from, subject, text, html }) => {
try {
// Verify transporter once before first send
if (!smtpVerified) {
if (!smtpVerifyPromise) {
smtpVerifyPromise = transport.verify()
.then(() => {
smtpVerified = true;
console.info("SMTP transporter verified");
})
.catch(err => {
console.warn("SMTP transporter verification failed", { message: err.message });
throw err;
});
}
await smtpVerifyPromise;
}

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +32
} catch (err) {
console.error("SendGrid email failed", { to, subject, message: err.message });
}
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The sendRaw function for SendGrid catches errors but doesn't re-throw them, causing the function to return undefined instead of propagating the error. This makes error handling inconsistent with the caller's expectations in sendWelcomeEmail.

Copilot uses AI. Check for mistakes.
Comment on lines +65 to +67
} catch (err) {
console.error("SMTP email failed", { to, subject, message: err.message });
}
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The sendRaw function for SMTP catches errors but doesn't re-throw them, causing the function to return undefined instead of propagating the error. This makes error handling inconsistent with the caller's expectations in sendWelcomeEmail.

Copilot uses AI. Check for mistakes.
@archa8
Copy link
Member

archa8 commented Oct 4, 2025

Kindly cross-link the corresponding issue. Thanks!

@onipinaka
Copy link
Author

I linked my PR with the issue, please Re-review

@onipinaka
Copy link
Author

@archa8 Please merge it.

@archa8
Copy link
Member

archa8 commented Oct 9, 2025

@onipinaka There are some conflicts right now. Kindly pull the recent changes and resolve the conflicts as pointed out by Git.

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.

feat: Send Welcome email on user signup

2 participants