This example shows how to use Mailtea with plain Node.js to send, schedule, reschedule, cancel, and batch transactional email from a single script — no framework, no build step.
To get the most out of this guide, you'll need to:
- Install dependencies:
npm install
- Copy
.env.exampleto.envand add your API key:cp .env.example .env
- Run it:
npm start
Everything lives in index.mjs, in seven numbered steps.
- Sending an HTML email with
emails.send - Sending
text+htmltogether, withreply_toandtags - Scheduling a send with
scheduled_at - Retrieving an email and its status with
emails.get - Moving a scheduled send with
emails.reschedule - Calling it off with
emails.cancel - Sending three emails in one request with
emails.batch - Catching
MailteaErrorand printing the status, code, and request id
npm testThe tests run against a bundled mock Mailtea server, so they need no API key and make no network calls.