Nodemailer
Send plain-text and HTML email from your Node.js application.
Before you begin, verify a sending domain and create an API key. Run this integration on your application server.
Install Nodemailer
In your Node.js project, install the package:
npm install nodemailerSend an email
Save this example as send-email.mjs:
import nodemailer from "nodemailer";
const transport = nodemailer.createTransport({
host: "smtp.sendy.stanleymasinde.com",
port: 2525,
secure: false,
requireTLS: true,
auth: {
user: "apikey",
pass: "API_KEY",
},
});
const result = await transport.sendMail({
from: "My App <[email protected]>",
to: "[email protected]",
subject: "Welcome",
text: "Your account is ready.",
html: "<h1>Welcome</h1><p>Your account is ready.</p>",
});
console.log(result.response); Replace API_KEY with your full API key, the sender with an address on your verified domain, and the recipient with your test address. Keep the key in your server’s secret configuration.
secure: false selects STARTTLS instead of implicit TLS. requireTLS: true requires the encrypted upgrade. See Nodemailer SMTP options.
Run the example:
node send-email.mjsRetry safely
Set headers on the sendMail message to provide an idempotency key:
headers: {
"Sendy-Idempotency-Key": "welcome/user-123",
},Use a key unique to the logical email and reuse it for retries. Matching submissions return the original job IDs without reserving credit again. Generated dates and message IDs can change, but other MIME bytes must match. If you send multipart messages or attachments, preserve the composed raw message so retries retain their boundaries and encoding. See SMTP idempotency behavior for key limits and conflict responses.
Check the result
The SMTP response contains the queued job IDs:
250 2.0.0 Queued jobs 123This confirms that Sendy queued the email. Check Emails or Get email status to follow delivery. For attachments and message limits, see SMTP.