Add transactional email service for auth and certificates (Nodemailer + templates)#234
Merged
portableDD merged 3 commits intoNexacore-Org:mainfrom Mar 29, 2026
Conversation
…graceful SMTP fallback
|
@Jayrodri088 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@Jayrodri088 please resolve conflicts |
4163132 to
dd0e5ee
Compare
…ayrodri088/ByteChain-Academy into feat-email-notfication-service
Contributor
Author
|
@portableDD Conflicts resolved |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a real backend email notification layer for ByteChain Academy and replaces the previous forgot-password stub behavior.
What was broken
The auth forgot-password flow generated a reset token but did not send an email, making password recovery non-functional in real deployments.
What this PR adds
EmailModuleandEmailServicepowered by Nodemailer..env.example.SMTP_HOSTis missing, email content is logged instead of throwing, so app behavior remains stable in local/dev/test environments.Scope of Changes
New files
backend/src/email/email.module.tsbackend/src/email/email.service.tsbackend/src/email/templates/welcome.template.tsbackend/src/email/templates/password-reset.template.tsbackend/src/email/templates/certificate.template.tsbackend/src/email/templates/streak-reminder.template.tsUpdated files
backend/src/auth/auth.service.tsbackend/src/auth/auth.module.tsbackend/src/certificates/certificates.service.tsbackend/src/certificates/certificates.module.tsbackend/src/app.module.tsbackend/.env.examplebackend/package.jsonbackend/package-lock.jsonImplementation Details
Email service design
EmailServicereads SMTP config fromConfigService:SMTP_HOSTSMTP_PORTSMTP_USERSMTP_PASSSMTP_FROM_NAMESMTP_FROM_EMAILSMTP_HOSTis present, service creates a Nodemailer transport and sends real emails.SMTP_HOSTis absent, service logs an email payload (to,subject,html) via NestLogger.Supported email methods
sendWelcomeEmail(to, username)sendPasswordResetEmail(to, resetToken, resetUrl)sendCertificateEmail(to, username, courseName, certificateHash, downloadUrl)sendStreakReminderEmail(to, username, streak)Template behavior
Each template returns
{ subject, html }and uses:Auth flow updates
register()now sends a welcome email after successful user creation.forgotPassword()now:CLIENT_URLfallback (http://localhost:3000)Certificate flow updates
issueCertificateForCourse()now sends certificate email after issuance, including:CLIENT_URLfallback-based)Config
Added to
.env.example:SMTP_HOST=SMTP_PORT=587SMTP_USER=SMTP_PASS=SMTP_FROM_NAME=ByteChain Academy[email protected]Backward Compatibility / Safety
Validation / Test Plan
SMTP_HOSTconfiguredCloses: #207