Send email with Nodemailer over SMTP
Nodemailer is not deprecated. Create a transport with createTransport, point it at smtp.unitpost.com on port 587 (STARTTLS) or 465 (implicit TLS), and send from a verified domain. Port 25 is blocked on most clouds — don't use it. The same transport works in Express, Next.js, and NestJS.
What are the SMTP settings?
| Host | smtp.unitpost.com |
|---|---|
| Username | unitpost(always this literal value) |
| Password | Your Unitpost API key(must carry emails:send) |
| Port (STARTTLS) | 587(or 2587 if blocked) |
| Port (implicit TLS) | 465(or 2465 if blocked) |
| From address | Any address on a verified domain |
How do I set it up?
Install Nodemailer
Add it to your Node.js project (Node 18+). The package is actively maintained.
Shellnpm install nodemailerCreate a transport
Point
createTransportatsmtp.unitpost.com. Use port 587 withsecure: falsefor STARTTLS, or port 465 withsecure: truefor implicit TLS. The username is alwaysunitpost; the password is your API key withemails:send.JavaScriptimport nodemailer from "nodemailer"; const transporter = nodemailer.createTransport({ host: "smtp.unitpost.com", port: 587, secure: false, requireTLS: true, auth: { user: "unitpost", pass: process.env.UNITPOST_API_KEY, }, });Port 25 vs 587: 25 is the legacy submission port and is blocked by AWS, GCP, and most VPS providers. 587 with STARTTLS is what you want. 465 is implicit TLS if 587 is filtered.
Send an email
The
fromaddress must be on a domain you've verified in Unitpost. This is the samesendMailcall in a Next.js Route Handler or a NestJS provider.JavaScriptawait transporter.sendMail({ from: "you@yourdomain.com", to: "customer@example.com", subject: "Hello from Unitpost", html: "<h1>Welcome!</h1><p>Sent via SMTP.</p>", });