Send transactional emails from Node.js — contact forms, booking confirmations, password resets — using Nodemailer with SMTP or a dedicated email service like Resend or SendGrid.
In this guide
Install: npm install nodemailer @types/nodemailer. Create a reusable transporter: import nodemailer from "nodemailer"; const transporter = nodemailer.createTransport({ host: process.env.SMTP_HOST, port: 587, secure: false, auth: { user: process.env.SMTP_USER, pass: process.env.SMTP_PASS } }). For Gmail, use port 587 with STARTTLS. For SSL, use port 465 with secure: true.
await transporter.sendMail({ from: "Your App <noreply@yourapp.com>", to: "user@example.com", subject: "Booking Confirmation", text: "Your booking is confirmed.", html: "<h1>Your booking is confirmed.</h1><p>We will see you soon.</p>" }). Always include both text and html versions — some email clients display plain text only. Use the text version as a fallback and for email clients that prefer it.
Using raw SMTP from a VPS often results in emails landing in spam. Use a dedicated sending service instead. Resend (resend.com) is developer-focused, has a generous free tier (3,000 emails/month), and integrates with React Email for templating. Install: npm install resend. Send: import { Resend } from "resend"; const resend = new Resend(process.env.RESEND_API_KEY); await resend.emails.send({ from: "...", to: "...", subject: "...", html: "..." }).
Raw HTML emails require inline CSS (most email clients strip <style> tags) and table-based layouts (Outlook requires tables). Use React Email (react.email) to build templates as React components with Tailwind-like props — it generates compatible HTML automatically. Or use MJML, a markup language designed for emails. Avoid CSS floats, position:absolute, and web fonts — test in Litmus or Email on Acid before sending.
Without proper DNS authentication, your emails land in spam. Add these records to your DNS: SPF (TXT record): "v=spf1 include:yoursendingservice.com ~all" — tells mail servers which IPs can send from your domain. DKIM: a cryptographic signature added by your sending service — add the TXT record they provide. DMARC (TXT record): "v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com" — tells mail servers what to do with failed authentication.
Need Help?
Our engineering team handles implementations like this every week. Get a free scoping call — we will tell you exactly what it takes and what it costs.
Book a free callCompetitive Intelligence
Efficiency Modeling
© 2026 NexWorldTech — Built for Global Dominance.