Send email from NestJS over SMTP
Inject a Nodemailer transport in NestJS and send over Unitpost SMTP. Same credentials as any other stack.
Install Nodemailer
Shellnpm install nodemailer npm install -D @types/nodemailerProvide a transporter
TypeScriptimport { Injectable } from "@nestjs/common"; import nodemailer from "nodemailer"; @Injectable() export class MailService { private transporter = nodemailer.createTransport({ host: "smtp.unitpost.com", port: 587, secure: false, auth: { user: "unitpost", pass: process.env.UNITPOST_API_KEY, }, }); sendWelcome(to: string) { return this.transporter.sendMail({ from: "you@yourdomain.com", to, subject: "Welcome", html: "<p>Sent via SMTP.</p>", }); } }Verify delivery
The send shows up in Activity. See also Nodemailer.