Skip to content

[BE-07] Set up Nodemailer email service with transactional email templates #880

Description

@yusuftomilola

Overview

nodemailer is installed but never configured. Email is required for: password reset links, 2FA backup codes, maintenance due alerts, warranty expiry notifications, and scheduled report delivery. This issue creates the shared mail infrastructure.

Context

  • package.json has nodemailer@7.0.12
  • backend/.env.example already defines MAIL_FROM, SMTP_HOST, SMTP_PORT, SMTP_SECURE, SMTP_USER, SMTP_PASS
  • Email sending must be async (enqueued via BullMQ from BE-04) so it never blocks HTTP responses
  • Templates must be clean and branded — include AssetsUp name, relevant details, and a clear call-to-action

Acceptance Criteria

  • Create src/mail/mail.module.ts and src/mail/mail.service.ts using nodemailer.createTransport() with SMTP config from ConfigService
  • Create src/mail/templates/ directory with HTML string templates for: welcome.ts, password-reset.ts, otp-code.ts, maintenance-alert.ts, warranty-alert.ts
  • MailService.sendMail({ to, subject, html }) wraps the transporter and catches SMTP errors without crashing the app
  • Create a BullMQ mail processor (src/mail/mail.processor.ts) that dequeues and sends email jobs from the MAIL_QUEUE
  • Add MailModule to AppModule imports and export MailService for other modules to inject
  • In NODE_ENV=development, log the email content to the console instead of sending (use Ethereal Mail or similar for local testing)

Metadata

Metadata

Assignees

Labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions