Send email in Node.js with an email API
Send transactional email in Node.js with the notifycx SDK or one fetch — no Nodemailer required.
Send transactional email from Node.js. Prefer the official notifycx SDK for TypeScript; plain fetch works too (Node 18+).
Prerequisites
- API key
- Verified domain for production custom
from
SDK (recommended)
npm install notifycx
import Notify from 'notifycx'
const notify = new Notify({ apiKey: process.env.NOTIFY_API_KEY! })
await notify.send({
from: 'noreply@your-verified-domain.com',
to: 'john@example.com',
subject: 'Hello world',
html: '<h1>Welcome!</h1><p>Thanks for joining us.</p>',
})
fetch
async function sendEmail() {
const response = await fetch('https://notify.cx/api/email/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.NOTIFY_API_KEY!
},
body: JSON.stringify({
from: 'noreply@your-verified-domain.com',
to: 'john@example.com',
subject: 'Hello world',
html: '<h1>Welcome!</h1><p>Thanks for joining us.</p>'
})
});
if (!response.ok) {
throw new Error(`Failed to send email: ${await response.text()}`);
}
console.log(await response.json());
}
sendEmail();
NOTIFY_API_KEY=your_key node send-email.js
Prefer html; message / text aliases work. See Sending Emails.